
Implemented a complete FastAPI backend with: - Project structure with FastAPI and SQLAlchemy - SQLite database with proper configuration - Alembic for database migrations - Generic Item resource with CRUD operations - REST API endpoints with proper validation - Health check endpoint - Documentation and setup instructions
20 lines
483 B
Python
20 lines
483 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.api import deps
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health", summary="Check service health")
|
|
def health_check(db: Session = Depends(deps.get_db)):
|
|
"""
|
|
Check service health:
|
|
- Database connection is active
|
|
- API is responding
|
|
"""
|
|
# Try to execute a simple query to check DB connection
|
|
db.execute("SELECT 1")
|
|
|
|
return {"status": "ok", "message": "Service is healthy"}
|