
- Created FastAPI application with SQLite database integration - Implemented OpenWeatherMap client with caching - Added endpoints for current weather, forecasts, and history - Included comprehensive error handling and validation - Set up Alembic migrations - Created detailed README with usage examples generated with BackendIM... (backend.im)
30 lines
858 B
Python
30 lines
858 B
Python
from fastapi import FastAPI
|
|
from app.api.routes import api_router
|
|
from app.core.config import settings
|
|
from app.core.exceptions import configure_exception_handlers
|
|
from app.database.session import Base, engine
|
|
|
|
# Create database tables
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title=settings.PROJECT_NAME,
|
|
description="Weather Data API for OpenWeatherMap",
|
|
version="0.1.0",
|
|
openapi_url=f"{settings.API_V1_STR}/openapi.json",
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
# Configure exception handlers
|
|
configure_exception_handlers(app)
|
|
|
|
# Include API routes
|
|
app.include_router(api_router, prefix=settings.API_V1_STR)
|
|
|
|
@app.get("/health", tags=["health"])
|
|
async def health_check():
|
|
"""
|
|
Health check endpoint to verify the API is running.
|
|
"""
|
|
return {"status": "ok", "message": "Weather Data API is operational"} |