2020logger = AppStructLogger ().get_logger ()
2121templates = Jinja2Templates (directory = Path (__file__ ).parent .parent / "templates" )
2222
23+
2324@asynccontextmanager
2425async def lifespan (app : FastAPI ):
2526 app .redis = await get_redis ()
@@ -30,12 +31,15 @@ async def lifespan(app: FastAPI):
3031 min_size = 5 ,
3132 max_size = 20 ,
3233 )
33- await logger .ainfo ("Postgres pool created" , idle_size = app .postgres_pool .get_idle_size ())
34+ await logger .ainfo (
35+ "Postgres pool created" , idle_size = app .postgres_pool .get_idle_size ()
36+ )
3437 yield
3538 finally :
3639 await app .redis .close ()
3740 await app .postgres_pool .close ()
3841
42+
3943def create_app () -> FastAPI :
4044 app = FastAPI (
4145 title = "Stuff And Nonsense API" ,
@@ -47,7 +51,9 @@ def create_app() -> FastAPI:
4751 app .include_router (shakespeare_router )
4852 app .include_router (user_router )
4953 app .include_router (ml_router , prefix = "/v1/ml" , tags = ["ML" ])
50- app .include_router (health_router , prefix = "/v1/public/health" , tags = ["Health, Public" ])
54+ app .include_router (
55+ health_router , prefix = "/v1/public/health" , tags = ["Health, Public" ]
56+ )
5157 app .include_router (
5258 health_router ,
5359 prefix = "/v1/health" ,
@@ -61,6 +67,7 @@ def get_index(request: Request):
6167
6268 return app
6369
70+
6471app = create_app ()
6572
6673# --- Unused/experimental code and TODOs ---
0 commit comments