25 lines
557 B
Python
25 lines
557 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from .database import engine, Base
|
|
from .routers import pos, generation, jobs
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="Language Learning API", lifespan=lifespan)
|
|
|
|
app.include_router(pos.router)
|
|
app.include_router(generation.router)
|
|
app.include_router(jobs.router)
|
|
|
|
|
|
@app.get("/health")
|
|
async def health() -> dict:
|
|
return {"status": "ok"}
|