Spaces:
Sleeping
Sleeping
| """ | |
| FastAPI application serving the interactive property price map. | |
| Serves static frontend files and pre-computed JSON price data. | |
| Designed for Hugging Face Spaces Docker deployment on port 7860. | |
| """ | |
| from pathlib import Path | |
| from fastapi import FastAPI | |
| from fastapi.middleware.gzip import GZipMiddleware | |
| from fastapi.responses import FileResponse | |
| from fastapi.staticfiles import StaticFiles | |
| ROOT = Path(__file__).resolve().parent | |
| DATA_DIR = ROOT / "data" / "aggregated" | |
| STATIC_DIR = ROOT / "static" | |
| app = FastAPI(title="French Property Prices", docs_url=None, redoc_url=None) | |
| app.add_middleware(GZipMiddleware, minimum_size=1000) | |
| async def index(): | |
| return FileResponse(STATIC_DIR / "index.html") | |
| # Serve static files (JS, CSS) | |
| app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static") | |
| # Serve data files (JSON, GeoJSON, PMTiles) - StaticFiles handles range requests | |
| # which is required for PMTiles (HTTP range-based tile fetching) | |
| app.mount("/data", StaticFiles(directory=DATA_DIR), name="data") | |