Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrannas committed Oct 30, 2024
1 parent 6dfb793 commit 046acd8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions panoptic_back/panoptic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@


def start():

@asynccontextmanager
async def lifespan(app: FastAPI):
yield
await panoptic.close()


panoptic = Panoptic()
panoptic.load_data()

Expand All @@ -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=["*"],
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions panoptic_back/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ dependencies = [
"starlette",
"uvicorn",
"pendulum",
"imagehash",
"pillow"
]

[project.urls]
Expand Down

0 comments on commit 046acd8

Please sign in to comment.