initial skeleton: FastAPI + SQLAlchemy + schema rendicontazione + template RE-START

This commit is contained in:
BFLOWS
2026-04-18 07:50:06 +02:00
commit 63fd2f66e6
14 changed files with 602 additions and 0 deletions

24
app/routers/health.py Normal file
View File

@@ -0,0 +1,24 @@
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from sqlalchemy import text
from ..db import get_db
router = APIRouter()
@router.get("/health")
def health(db: Session = Depends(get_db)):
# Verifica connessione DB e schema
try:
result = db.execute(text("SELECT current_schema(), current_user, now();")).first()
return {
"status": "ok",
"service": "rendicontazione-api",
"db": {
"schema": result[0],
"user": result[1],
"now": str(result[2]),
},
}
except Exception as e:
return {"status": "degraded", "error": str(e)}