Большие изменения с добавленем Alembic

This commit is contained in:
2024-07-31 22:56:31 +09:00
parent a2a400fff3
commit 7c70f82a21
19 changed files with 528 additions and 39 deletions

View File

@ -4,21 +4,32 @@ from fastapi.responses import ORJSONResponse
from core.settings import settings
from api.main_router import router as main_router
from api.another_router import router as another_router
from core.models import db_helper
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app: FastAPI):
#start up
yield
#shutdown
await db_helper.dispose()
app = FastAPI(default_response_class=ORJSONResponse)
main_app = FastAPI(
lifespan=lifespan,
default_response_class=ORJSONResponse
)
#api/hello
app.include_router(
main_app.include_router(
router=main_router,
prefix="/api",
tags=["Основной роутер"]
)
app.include_router(
main_app.include_router(
router=another_router,
prefix="/another",
tags=["Побочный роутер"]
)
if __name__ == "__main__":
uvicorn.run(app, host=settings.run.host, port=settings.run.port)
uvicorn.run(main_app, host=settings.run.host, port=settings.run.port)