sourcecred/scripts
William Chargin 4d77516bf4
api: add server for easy Observable integration (#1537)
Summary:
This commit adds a simple Python server for connecting the output of
`yarn api` (or `yarn api --watch`) to an observable notebook. We need a
custom server rather than just `python3 -m http.server` to send CORS
headers properly. This server enables a very tight loop from editing
SourceCred core code on your local filesystem to seeing live updates in
an Observable notebook, with latency on the order of one second.

Test Plan:
Run `yarn api --watch` in the background. Launch the new API server.
Navigate to <https://observablehq.com/demo>. Copy the two paragraphs of
Observable code from `scripts/serve_api.py` into _separate_ Observable
cells, and execute them. Note that `myGraph` becomes a valid SourceCred
graph. Modify `src/core/graph.js` to add `this._aaa = 123;` to the top
of the `Graph` constructor. Re-execute the first Observable cell (the
one that loads the SourceCred module), and note that `myGraph` updates
to include the new `_aaa` attribute:

![Screenshot of Observable notebook after test plan][ss]

[ss]: https://user-images.githubusercontent.com/4317806/71958748-dddf8680-31a5-11ea-9016-5df76ceeea46.png

wchargin-branch: api-server
2020-01-09 21:33:09 -08:00
..
build_static_site.sh Hackily add support for mixed GitHub/Discourse projects (#1378) 2019-09-12 17:35:21 +02:00
check-gnu-coreutils.sh Add helpful message when missing gnu-coreutils (#1034) 2019-01-05 12:20:07 -08:00
check-stopships.sh Permit STOPSHIPs in Markdown files (#573) 2018-07-31 10:58:29 -07:00
deploy.sh Include full projects on sourcecred.io (#1270) 2019-08-07 20:07:31 +02:00
docker-entrypoint.sh Adding Docker container with instructions for running sourcecred (#1288) 2019-08-23 13:23:35 +02:00
ensure-flow.sh ensure-flow.sh: simplify, removing dep on GNU grep (#602) 2018-08-22 11:44:20 -07:00
serve_api.py api: add server for easy Observable integration (#1537) 2020-01-09 21:33:09 -08:00
update_snapshots.sh update_snapshots: fix Discourse key check (#1360) 2019-09-07 16:27:29 -07:00