first commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from fastapi import APIRouter, HTTPException, status
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.deps import DbSession
|
||||
|
||||
|
||||
router = APIRouter(tags=["系统"])
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
async def health(db: DbSession) -> dict[str, str]:
|
||||
try:
|
||||
await db.execute(text("select 1"))
|
||||
except Exception as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="数据库不可用",
|
||||
) from exc
|
||||
return {"status": "ok", "database": "ok"}
|
||||
Reference in New Issue
Block a user