diff --git a/panoptic_back/panoptic/main.py b/panoptic_back/panoptic/main.py index aab2ccff..f364b35a 100644 --- a/panoptic_back/panoptic/main.py +++ b/panoptic_back/panoptic/main.py @@ -14,6 +14,13 @@ def start(): + + @asynccontextmanager + async def lifespan(app: FastAPI): + yield + await panoptic.close() + + panoptic = Panoptic() panoptic.load_data() @@ -22,7 +29,7 @@ def start(): PORT = os.getenv("PANOPTIC_PORT", 8000) # FastAPI setup - app = FastAPI() + app = FastAPI(lifespan=lifespan) app.add_middleware( CORSMiddleware, allow_origins=["*"], @@ -53,10 +60,6 @@ def start(): # async def shutdown_event(): # await panoptic.close() - @asynccontextmanager - async def lifespan(app: FastAPI): - yield - await panoptic.close() uvicorn.run(app, host=HOST, port=PORT) diff --git a/panoptic_back/pyproject.toml b/panoptic_back/pyproject.toml index 26364ebc..1f1735e5 100644 --- a/panoptic_back/pyproject.toml +++ b/panoptic_back/pyproject.toml @@ -50,6 +50,8 @@ dependencies = [ "starlette", "uvicorn", "pendulum", + "imagehash", + "pillow" ] [project.urls]