diff --git a/sfm/server.py b/sfm/server.py index e277948..1ce3b37 100644 --- a/sfm/server.py +++ b/sfm/server.py @@ -57,6 +57,7 @@ try: from fastapi import Body, FastAPI, File, HTTPException, Query, Response, UploadFile from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import FileResponse, JSONResponse, StreamingResponse + from fastapi.staticfiles import StaticFiles from pydantic import BaseModel import uvicorn except ImportError: @@ -118,6 +119,20 @@ app.add_middleware( ) +class _PageScripts(StaticFiles): + """sfm/static/: the web page's JavaScript (no inline JS -- a stack-wide rule, + 2026-11-02). `no-cache` makes the browser revalidate on every load, a cheap + 304, so a page served by a new SFM never runs an old SFM's cached script.""" + + async def get_response(self, path, scope): + response = await super().get_response(path, scope) + response.headers["Cache-Control"] = "no-cache" + return response + + +app.mount("/static", _PageScripts(directory=str(Path(__file__).parent / "static")), name="static") + + # ── DB ──────────────────────────────────────────────────────────────────────── # Shared SeismoDb instance. Path can be overridden by --db-path at startup, # or defaults to bridges/captures/seismo_relay.db relative to the repo root. diff --git a/sfm/sfm_webapp.html b/sfm/sfm_webapp.html index 327d0e9..ab442e8 100644 --- a/sfm/sfm_webapp.html +++ b/sfm/sfm_webapp.html @@ -1472,2441 +1472,8 @@ - - + +