Add an example site that calls every route, served at /examples/

A reader learns the API fastest from working calls: one page per area
(circuit browser, track images, GPS traces on a map, grand prix lookup,
posters, Kometa) shows the exact request URL next to its answer. Pages
call their own origin when the app serves them, and the public service
when opened from disk or given ?api=. Posters render only on a button
press, since each one fetches map tiles on the server. A body that does
not match the asked format is said in red, never shown as success.

The image copies examples/ so the deployed app serves the same pages.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
This commit is contained in:
2026-11-27 09:48:04 +01:00
parent 3271e2d563
commit b6e6e9d565
12 changed files with 2027 additions and 1 deletions
+13 -1
View File
@@ -1,6 +1,7 @@
from fastapi import FastAPI, HTTPException, Response
from fastapi.responses import FileResponse, Response as FastAPIResponse, PlainTextResponse
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from pathlib import Path
import logging
@@ -79,10 +80,21 @@ async def root():
"/grand-prix/{grand_prix_name}/year/{year}",
"/posters/race/{grand_prix_name}/{season}.png",
"/posters/season/{season}.png",
]
"/posters/session/{grand_prix_name}/{season}/{session_slug}.png",
"/kometa/formula-1-metadata.yml",
],
"examples": "/examples/",
}
# The example site: one page per area of the API, each calling the routes above (examples/index.html).
app.mount(
"/examples",
StaticFiles(directory=Path(__file__).resolve().parent / "examples", html=True),
name="examples",
)
@app.get("/posters/race/{grand_prix_name}/{season}.png")
async def get_race_poster(grand_prix_name: str, season: int, bg: BackgroundStyle = BackgroundStyle.AERIAL):
"""Plex-ready 1000x1500 race poster (PNG). Cached on disk per (race, bg).