PIbd-42_Kashin_M.I_FinalQua.../fastapi-app/main.py

21 lines
474 B
Python
Raw Normal View History

2024-12-17 00:31:14 +04:00
from fastapi import FastAPI
from contextlib import asynccontextmanager
from database import create_tables, delete_tables
from router import router as tasks_router
@asynccontextmanager
async def lifespan(app: FastAPI):
await delete_tables()
print("База очищена")
await create_tables()
print("База готова к работе")
yield
print("Выключение")
app = FastAPI(lifespan=lifespan)
app.include_router(tasks_router)