service_man/api/app_builder/main.py

25 lines
471 B
Python

from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from fastapi import FastAPI
from api.app_builder.dependencies import init_dependencies
from .routers import init_routers
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator:
print("init lifespan")
yield
def app_factory() -> FastAPI:
app = FastAPI(
lifespan=lifespan,
)
init_dependencies(app)
init_routers(app)
return app