Automated Action ef0bc51fbb Create simple FastAPI todo application
- Set up project structure with proper directory layout
- Implemented SQLite database with SQLAlchemy ORM
- Created Todo model with CRUD operations
- Added Alembic for database migrations
- Implemented RESTful API endpoints for todos
- Added health check endpoint
- Configured CORS for all origins
- Created comprehensive documentation
- Added linting with Ruff
2025-06-17 06:40:03 +00:00

23 lines
600 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.db.session import get_db
router = APIRouter()
@router.get("/health")
def health_check(db: Session = Depends(get_db)):
try:
# Test database connection
db.execute("SELECT 1")
return {
"status": "healthy",
"database": "connected",
"service": "todo-api"
}
except Exception as e:
return {
"status": "unhealthy",
"database": "disconnected",
"service": "todo-api",
"error": str(e)
}