
- Set up project structure with FastAPI and SQLite - Implement Todo model, schemas, and CRUD operations - Set up Alembic for database migrations - Add health endpoint for application monitoring - Update README with project information generated with BackendIM... (backend.im)
21 lines
510 B
Python
21 lines
510 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from app.database import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/health")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
"""Health check endpoint"""
|
|
# Test database connection
|
|
try:
|
|
db.execute("SELECT 1")
|
|
db_status = "healthy"
|
|
except Exception as e:
|
|
db_status = f"unhealthy: {str(e)}"
|
|
|
|
return {
|
|
"status": "ok",
|
|
"db_status": db_status,
|
|
"version": "0.1.0"
|
|
} |