diff --git a/CHANGELOG.md b/CHANGELOG.md index 980a9b7..9e2e796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Removed the example of an old json submission (before 2022-11-21) - Updated actions using the latest base images and to run using Python 3.9 - Docker image uses Python 3.11 instead of 3.8 +- Replaced deprecated app "on event" with app lifespan ### Fixed - Updated issue templates - Updated a number of libraries to address all current security advisories diff --git a/preClinVar/main.py b/preClinVar/main.py index da7421c..beb0e88 100644 --- a/preClinVar/main.py +++ b/preClinVar/main.py @@ -1,6 +1,7 @@ import json import logging import re +from contextlib import asynccontextmanager from typing import List import requests @@ -16,16 +17,18 @@ LOG = logging.getLogger("uvicorn.access") -app = FastAPI() - -@app.on_event("startup") -async def startup_event(): +@asynccontextmanager +async def lifespan(app_: FastAPI): LOG = logging.getLogger("uvicorn.access") console_formatter = uvicorn.logging.ColourizedFormatter( "{levelprefix} {asctime} : {message}", style="{", use_colors=True ) LOG.handlers[0].setFormatter(console_formatter) + yield + + +app = FastAPI(lifespan=lifespan) @app.get("/")