
- 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
23 lines
600 B
Python
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)
|
|
} |