2024-05-25 16:11:52 +04:00
|
|
|
from fastapi import FastAPI
|
2024-05-25 16:51:34 +04:00
|
|
|
import logging
|
2024-05-25 16:11:52 +04:00
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
|
2024-06-08 01:22:35 +04:00
|
|
|
|
2024-06-02 17:33:50 +04:00
|
|
|
from router_questions import router as questions_router
|
|
|
|
from router_class import router as class_router
|
2024-06-06 22:49:43 +04:00
|
|
|
from router_flight import router as flight_router
|
2024-06-06 23:37:38 +04:00
|
|
|
from router_reviews import router as reviews_router
|
2024-06-08 01:22:35 +04:00
|
|
|
from router_statistics import router as statistic_router
|
2024-05-25 16:11:52 +04:00
|
|
|
|
2024-05-25 16:51:34 +04:00
|
|
|
# Настройка логирования
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
logger = logging.getLogger(__name__)
|
2024-05-25 16:11:52 +04:00
|
|
|
|
|
|
|
@asynccontextmanager
|
|
|
|
async def lifespan(app: FastAPI):
|
2024-05-25 16:51:34 +04:00
|
|
|
logger.info("База данных готова к работе")
|
2024-05-25 16:11:52 +04:00
|
|
|
yield
|
2024-05-25 16:51:34 +04:00
|
|
|
logger.info("Выключение")
|
2024-05-25 16:11:52 +04:00
|
|
|
|
|
|
|
app = FastAPI(lifespan=lifespan)
|
2024-05-25 16:51:34 +04:00
|
|
|
app.include_router(questions_router)
|
2024-06-02 17:33:50 +04:00
|
|
|
app.include_router(class_router)
|
2024-06-06 22:49:43 +04:00
|
|
|
app.include_router(flight_router)
|
2024-06-06 23:37:38 +04:00
|
|
|
app.include_router(reviews_router)
|
2024-06-08 01:22:35 +04:00
|
|
|
app.include_router(statistic_router)
|
2024-06-06 22:49:43 +04:00
|
|
|
|