PIbd-32_Kashin_M.I_API_Cour.../main.py

34 lines
980 B
Python
Raw Permalink Normal View History

from fastapi import FastAPI
import logging
from contextlib import asynccontextmanager
2024-06-11 23:38:00 +04:00
from gigachat import get_token
from password.config import auth
from router_questions import router as questions_router
from router_class import router as class_router
from router_flight import router as flight_router
from router_reviews import router as reviews_router
2024-06-08 01:22:35 +04:00
from router_statistics import router as statistic_router
# Настройка логирования
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@asynccontextmanager
async def lifespan(app: FastAPI):
logger.info("База данных готова к работе")
2024-06-11 23:38:00 +04:00
global giga_token
giga_token = get_token(auth)
yield
logger.info("Выключение")
app = FastAPI(lifespan=lifespan)
app.include_router(questions_router)
app.include_router(class_router)
app.include_router(flight_router)
app.include_router(reviews_router)
2024-06-08 01:22:35 +04:00
app.include_router(statistic_router)