Automated Action 1468af1391 Add Weather Data API with OpenWeatherMap integration
- 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)
2025-05-12 14:26:44 +00:00

33 lines
931 B
Python

import os
from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
from dotenv import load_dotenv
# Load .env file if it exists
load_dotenv()
class Settings(BaseSettings):
API_V1_STR: str = "/api/v1"
PROJECT_NAME: str = "Weather Data API"
# OpenWeatherMap API
OPENWEATHERMAP_API_KEY: str = "bd5e378503939ddaee76f12ad7a97608"
OPENWEATHERMAP_API_URL: str = "https://api.openweathermap.org/data/2.5"
# Cache settings
CACHE_EXPIRE_IN_SECONDS: int = 1800 # 30 minutes
# Database settings
DB_DIR = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=True,
)
settings = Settings()
# Create DB directory if it doesn't exist
settings.DB_DIR.mkdir(parents=True, exist_ok=True)