Spaces:
Running
Running
BYPASS STATIC FILE CACHING - Serve map directly through FastAPI
Browse filesHugging Face static file serving is clearly cached/broken.
Now serving map.html directly through FastAPI endpoints:
- /map
- /static/map.html (override)
This bypasses HF's static file caching entirely with explicit no-cache headers.
If this doesn't work, it's a deeper HF infrastructure issue.
app.py
CHANGED
@@ -487,6 +487,27 @@ async def read_root():
|
|
487 |
raise
|
488 |
|
489 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
@app.get("/api/trees", response_model=list[Tree], tags=["Trees"])
|
491 |
async def get_trees(
|
492 |
limit: int = 100,
|
|
|
487 |
raise
|
488 |
|
489 |
|
490 |
+
@app.get("/map", response_class=HTMLResponse, tags=["Frontend"])
|
491 |
+
@app.get("/static/map.html", response_class=HTMLResponse, tags=["Frontend"])
|
492 |
+
async def serve_map():
|
493 |
+
"""Serve the map page directly through FastAPI to bypass static caching"""
|
494 |
+
try:
|
495 |
+
with open("static/map.html", encoding="utf-8") as f:
|
496 |
+
content = f.read()
|
497 |
+
# Force no-cache headers
|
498 |
+
response = HTMLResponse(content=content)
|
499 |
+
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
|
500 |
+
response.headers["Pragma"] = "no-cache"
|
501 |
+
response.headers["Expires"] = "0"
|
502 |
+
return response
|
503 |
+
except FileNotFoundError:
|
504 |
+
logger.error("map.html not found")
|
505 |
+
raise HTTPException(status_code=404, detail="Map page not found")
|
506 |
+
except Exception as e:
|
507 |
+
logger.error(f"Error serving map page: {e}")
|
508 |
+
raise
|
509 |
+
|
510 |
+
|
511 |
@app.get("/api/trees", response_model=list[Tree], tags=["Trees"])
|
512 |
async def get_trees(
|
513 |
limit: int = 100,
|