Implement versioned asset loading and enhance homepage response. Added API endpoint for intake choices.
Browse files
app.py
CHANGED
|
@@ -28,9 +28,25 @@ app = Server(title="Borderless - Immigration Research Agent")
|
|
| 28 |
demo = app
|
| 29 |
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
@app.get("/", response_class=HTMLResponse)
|
| 32 |
-
async def homepage() ->
|
| 33 |
-
return (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
@app.get("/api/auth/status")
|
|
|
|
| 28 |
demo = app
|
| 29 |
|
| 30 |
|
| 31 |
+
def _versioned_homepage_html() -> str:
|
| 32 |
+
html = (ASSETS_DIR / "index.html").read_text(encoding="utf-8")
|
| 33 |
+
for asset in ("app.js", "globe.js", "server.css", "globe.css"):
|
| 34 |
+
version = int((ASSETS_DIR / asset).stat().st_mtime)
|
| 35 |
+
html = html.replace(f"/assets/{asset}", f"/assets/{asset}?v={version}")
|
| 36 |
+
return html
|
| 37 |
+
|
| 38 |
+
|
| 39 |
@app.get("/", response_class=HTMLResponse)
|
| 40 |
+
async def homepage() -> HTMLResponse:
|
| 41 |
+
return HTMLResponse(
|
| 42 |
+
content=_versioned_homepage_html(),
|
| 43 |
+
headers={"Cache-Control": "no-cache, must-revalidate"},
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
@app.get("/api/intake_choices")
|
| 48 |
+
def api_intake_choices() -> dict[str, Any]:
|
| 49 |
+
return server_api.get_intake_choices()
|
| 50 |
|
| 51 |
|
| 52 |
@app.get("/api/auth/status")
|