Automated Action 6705b7a5e2 Create Weather Data API with OpenWeatherMap integration
- Implemented FastAPI application structure
- Added OpenWeatherMap API integration
- Created SQLite database with SQLAlchemy
- Setup Alembic for database migrations
- Added health check endpoint
- Created comprehensive README

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

25 lines
591 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from datetime import datetime
from app.db.session import get_db
router = APIRouter()
@router.get("/health", tags=["health"])
def health_check(db: Session = Depends(get_db)):
"""
Health check endpoint
"""
try:
# Check database connection
db.execute("SELECT 1")
db_status = "healthy"
except Exception as e:
db_status = f"unhealthy: {str(e)}"
return {
"status": "healthy",
"timestamp": datetime.utcnow(),
"database": db_status
}