diff --git a/projects/radio-show/audio-processor/server/main.py b/projects/radio-show/audio-processor/server/main.py index 502ae67..bff4dbc 100644 --- a/projects/radio-show/audio-processor/server/main.py +++ b/projects/radio-show/audio-processor/server/main.py @@ -20,7 +20,7 @@ from contextlib import asynccontextmanager from pathlib import Path from fastapi import FastAPI, HTTPException, Query -from fastapi.responses import HTMLResponse +from fastapi.responses import FileResponse, HTMLResponse DB_PATH = os.environ.get("ARCHIVE_DB", "/data/archive.db") PORT = int(os.environ.get("PORT", "8765")) @@ -218,6 +218,23 @@ def stats(): return {"counts": counts, "by_year": by_year} +@app.get("/api/db.sqlite") +def download_db(): + """Stream the read-only archive.db for offline laptop sync. + + Anyone who can reach /api/search can already read every transcript, + so exposing the underlying SQLite file adds no meaningful disclosure. + Sync side: curl -o archive.db :/api/db.sqlite + """ + if not Path(DB_PATH).exists(): + raise HTTPException(404, "archive db not present") + return FileResponse( + DB_PATH, + media_type="application/vnd.sqlite3", + filename="archive.db", + ) + + @app.get("/", response_class=HTMLResponse) def index(): return INDEX_HTML