/
saba07022001
/
intelclinic
Обзор
Документация
Войти
/
saba07022001
/
intelclinic
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
api/application.py
52 строки
1 KB
saba070201
Initial commit
04 янв 2025, 01:31
04 янв 2025, 01:31
b450ee4
Код
Авторство
О чём код?
import aerich from fastapi import FastAPI from apps.router import router from core.middlewares import MIDDLEWARES from core.tortoise_orm.config import DB_CONFIG from utils.postgres_client import PostgresClient from fastapi.staticfiles import StaticFiles from pathlib import Path from core.settings import get_settings settings = get_settings() def create_app(): app = FastAPI( redoc_url=None, docs_url="/swagger/", openapi_url="/api/openapi.json", middleware=MIDDLEWARES, ) app.include_router(prefix="/v1", router=router) @app.on_event("startup") async def startup_event(): # Apply new migrations aerich_command = aerich.Command( tortoise_config=DB_CONFIG, location="./core/aerich/migrations" ) await PostgresClient.start() await aerich_command.init() await aerich_command.upgrade(run_in_transaction=False) @app.on_event("shutdown") async def shutdown_event(): await PostgresClient.close() return app async def on_commands(): aerich_command = aerich.Command( tortoise_config=DB_CONFIG, location="./core/aerich/migrations" ) await PostgresClient.start() await aerich_command.init() await aerich_command.upgrade(run_in_transaction=False)