Files
MAIA/backend/main.py
c-d-p 62d6b8bdfd [V1.0] Working application, added notifications.
Ready to upload to store.
2025-04-27 00:39:52 +02:00

41 lines
1000 B
Python

from contextlib import _AsyncGeneratorContextManager, asynccontextmanager
from typing import Any, Callable
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from core.database import get_engine, Base
from modules import router
import logging
logging.getLogger("passlib").setLevel(logging.ERROR) # fix bc package logging is broken
def lifespan_factory() -> Callable[[FastAPI], _AsyncGeneratorContextManager[Any]]:
@asynccontextmanager
async def lifespan(app: FastAPI):
# Base.metadata.drop_all(bind=get_engine())
Base.metadata.create_all(bind=get_engine())
yield
return lifespan
lifespan = lifespan_factory()
app = FastAPI(lifespan=lifespan)
app.include_router(router)
app.add_middleware(
CORSMiddleware,
allow_origins=[
"https://maia.depaoli.id.au",
"http://localhost:8081",
],
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/api/health")
def health():
return {"status": "ok"}