Serve the picks from the API, so the live picker reads them

The picker read circuits/photos.json and seasons/photos.json relative to
itself. The API serves only /examples/, so the live page showed two HTTP
404 errors and a "Load it from disk" box for each.

The API now serves both picks files, read-only, at /picks/circuits.json
and /picks/seasons.json. Each answer is the file as the poster service
has it loaded, from the same loader it draws from: the notes first, then
the entries, a refused entry left out. The root route lists both routes.

The picker reads them from the API its site picks. Only a page opened
from a working copy (file:, or a loopback host) falls back to the
repository's files. A failure names each address and why.

Builds: docs/posters.md, Picking photos, as written in 780984064f (the lead's lines 1-4 of 2026-11-30 and answers Q1, Q2)

Claude-Session: https://claude.ai/code/session_01JG73KFhbaNj3tyJ8tKmE3W
This commit is contained in:
2026-11-30 10:18:16 +01:00
parent 780984064f
commit 250828710c
7 changed files with 148 additions and 51 deletions
+15
View File
@@ -95,6 +95,7 @@ async def root():
"/posters/session/{grand_prix_name}/{season}/{session_slug}.png",
"/kometa/formula-1-metadata.yml",
"/licences",
*poster_sources.PICKS_ROUTES,
],
"examples": "/examples/",
"disclaimer": DISCLAIMER,
@@ -117,6 +118,20 @@ async def get_licences():
return poster_sources.licences()
def picks_route(path: Path):
"""A picks file, read-only, as the poster service has it loaded: its notes, then the entries it draws from (an
entry it refused is left out). Plain def: a changed file is read again, in the threadpool."""
def answer():
return posters_service.picks.answer(path)
return answer
# /picks/circuits.json and /picks/seasons.json (docs/posters.md, Picking photos).
for route, picks_path in poster_sources.PICKS_ROUTES.items():
app.get(route, name=f"picks_{picks_path.parent}",
summary=f"The picks of {picks_path}, as the poster service draws from them")(picks_route(picks_path))
# The example site: one page per area of the API, each calling the routes above (examples/index.html).
app.mount(
"/examples",