Get startedExercises
Exercise 02: add a route and watch the gates
Page actions
- View as Markdown (opens in a new tab)
- Ask ChatGPT (opens in a new tab)
- Ask Claude (opens in a new tab)
ChatGPT and Claude are third-party services. The link gives them this page's public address and a short instruction. This site records nothing.
Preview: the published page may be older or missing.
Add a harmless read-only route in a scratch branch and let the tests, the OpenAPI check and the generated routes page show every place a route must be declared — then throw it away.
https://docs.gurbanisoul.com/exercises/02-add-a-route/
Goal. Learn where a route lives by adding one and watching what breaks. Needs. the local setup, a scratch branch. 60 minutes. You will not keep the route.
1. A scratch branch
git switch -c scratch/exercise-02 integration2. Add the handler
In webapp/sggs/reader.py, after _route_meta, add a handler that returns the counts the
health check already knows:
def _route_counts(p, qs): return {'lines': db().execute('SELECT count(*) FROM lines').fetchone()[0], 'angs': db().execute('SELECT count(DISTINCT ang) FROM lines').fetchone()[0]}Register it in webapp/serve.py’s ROUTES table as ('counts', None): (_route_counts, 'reader')
(import it beside the other reader handlers). Start the server and call
curl -s http://127.0.0.1:7777/api/counts. Expected: {"lines": 60658, "angs": 1430}.
3. Watch the gates
make test-webExpected: failures — and each one names a place you have not yet declared the route:
- the OpenAPI test:
contract/openapi.jsondoes not cover every dispatcher route → declare it intools/gen_openapi.py:ROUTESand runmake openapi; - the declared-tables test: your handler read
lines— the reader context declares it, so this one passes; had you read another table, it would have failed and told you to add it toTABLES; - the routes-page check:
python3 tools/gen_route_table.py --check→ regeneratedocs/api/routes.md.
Fix each, rerun make test-web, and confirm it is green. Then run make docs-check: the
generated page is current again.
4. Throw it away
git switch integration && git branch -D scratch/exercise-02Self-check
Sri Guru Granth Sahib Ji — Knowledge Base wiki. Generated from commit c3d9360. Updated 25 September 2026. This copy may be out of date; the page is at https://docs.gurbanisoul.com/exercises/02-add-a-route/