24 lines
593 B
Python
24 lines
593 B
Python
import uvicorn
|
|
from fastapi import FastAPI
|
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
from database.database import create_tables, delete_tables
|
|
from routers.uploaded_file_router import router as csv_router
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await delete_tables()
|
|
print("База очищена")
|
|
await create_tables()
|
|
print("База готова к работе")
|
|
yield
|
|
print("Выключение")
|
|
|
|
app = FastAPI(lifespan=lifespan)
|
|
app.include_router(csv_router)
|
|
|
|
if __name__ == '__main__':
|
|
uvicorn.run(app, host='localhost', port=8000)
|