formaptix-server/main.py

26 lines
556 B
Python
Raw Normal View History

2024-08-08 22:14:02 +03:00
import logging
from contextlib import asynccontextmanager
import uvicorn
from fastapi import FastAPI
import models
import database
import routes
2024-08-08 22:14:02 +03:00
logging.basicConfig(level=logging.INFO)
@asynccontextmanager
async def lifespan(app: FastAPI):
logging.info("Creating tables in database")
async with database.engine.begin() as connection:
await connection.run_sync(database.Base.metadata.create_all)
yield
2024-08-10 17:01:34 +03:00
2024-08-08 22:14:02 +03:00
app = FastAPI(lifespan=lifespan)
app.include_router(routes.router)
2024-08-08 22:14:02 +03:00
uvicorn.run(app, host="0.0.0.0", port=models.settings.port)