feat: add versioned backend scoring workflow
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from .api import router
|
||||
from .db import SessionLocal
|
||||
from .seed import seed_initial
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s %(message)s")
|
||||
@asynccontextmanager
|
||||
async def lifespan(_app: FastAPI):
|
||||
with SessionLocal() as db:
|
||||
seed_initial(db)
|
||||
yield
|
||||
|
||||
|
||||
app = FastAPI(title="WiseGrade 智评", version="0.1.0", lifespan=lifespan)
|
||||
app.include_router(router)
|
||||
|
||||
|
||||
@app.exception_handler(ValueError)
|
||||
async def value_error_handler(_request: Request, exc: ValueError):
|
||||
return JSONResponse(status_code=400, content={"detail": str(exc)})
|
||||
|
||||
|
||||
@app.get("/api/health")
|
||||
def health():
|
||||
return {"status": "ok"}
|
||||
Reference in New Issue
Block a user