"""Container entrypoint: serve the Flask API and the built SPA from one process. Upstream's backend/serve.py does this too, but it also shells out to `npm run build` and tries to launch a browser, neither of which works in a container. """ from pathlib import Path from flask import send_file, send_from_directory from app import app # importing app runs init_db(), creating the SQLite schema DIST = Path(__file__).parent / "dist" @app.route("/") def _index(): return send_file(DIST / "index.html") @app.route("/") def _static(path): asset = DIST / path if asset.is_file(): return send_from_directory(DIST, path) if path.startswith("api/"): return {"error": "Not found"}, 404 return send_file(DIST / "index.html") # SPA client-side routing