Automated Action cd7c0162fe Create REST API with FastAPI and SQLite
- Implemented project structure with FastAPI framework
- Set up SQLite database with SQLAlchemy ORM
- Created Alembic for database migrations
- Implemented Item model and CRUD operations
- Added health check endpoint
- Added error handling
- Configured API documentation with Swagger UI

generated with BackendIM... (backend.im)
2025-05-13 15:58:51 +00:00

26 lines
597 B
Python

from datetime import datetime
from fastapi import APIRouter, Depends, status
from sqlalchemy.orm import Session
from app.database import get_db
from app import schemas
router = APIRouter()
@router.get("/", response_model=schemas.HealthCheck)
def health_check(db: Session = Depends(get_db)):
"""
Health check endpoint
"""
# Verify database connection is working
try:
db.execute("SELECT 1")
db_status = "healthy"
except Exception:
db_status = "unhealthy"
return {
"status": db_status,
"timestamp": datetime.now()
}