sipi-web/sipi-app/main.py

32 lines
694 B
Python
Raw Normal View History

2024-07-11 16:01:26 +00:00
from contextlib import asynccontextmanager
from core.config import settings
from core.models import db_helper
from api import router as api_router
import uvicorn
from fastapi import FastAPI
2024-07-12 11:49:52 +00:00
from fastapi.responses import ORJSONResponse
2024-07-11 16:01:26 +00:00
@asynccontextmanager
async def lifespan(app: FastAPI):
yield
await db_helper.dispose()
main_app = FastAPI(
2024-07-12 11:49:52 +00:00
default_response_class=ORJSONResponse,
2024-07-11 16:01:26 +00:00
lifespan=lifespan,
)
2024-07-11 16:01:26 +00:00
main_app.include_router(api_router,
prefix=settings.api.prefix)
if __name__ == '__main__':
uvicorn.run('main:main_app',
host=settings.run.host,
port=settings.run.port,
reload=settings.run.reload)