Automated Action b00b44023a Add FastAPI REST API with SQLite database
- Set up project structure
- Add database models and SQLAlchemy setup
- Configure Alembic for migrations
- Create API endpoints for items
- Add health check endpoint
- Update documentation

generated with BackendIM... (backend.im)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 22:33:58 +00:00

25 lines
667 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.database.session import get_db
router = APIRouter()
@router.get("", response_model=dict)
def health_check(db: Session = Depends(get_db)):
"""
Health check endpoint to verify API and database are working
"""
try:
# Check if DB connection is working
db.execute("SELECT 1")
return {
"status": "ok",
"message": "API is healthy and database connection is working"
}
except Exception as e:
return {
"status": "error",
"message": f"Database connection failed: {str(e)}"
}