Fix loading times
This commit is contained in:
parent
f685bdca04
commit
2f41c38cc4
4 changed files with 34 additions and 18 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
|
@ -5,7 +6,16 @@ from fastapi.staticfiles import StaticFiles
|
|||
|
||||
from server.routes import hexagons
|
||||
|
||||
app = FastAPI(title="Property Map API")
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# Startup: preload all parquet files
|
||||
hexagons.preload_dataframes()
|
||||
yield
|
||||
# Shutdown: nothing to clean up
|
||||
|
||||
|
||||
app = FastAPI(title="Property Map API", lifespan=lifespan)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue