
- Set up FastAPI project structure - Create database models for locations and weather data - Implement OpenWeatherMap API integration - Create API endpoints for current weather and history - Add health endpoint - Set up database migrations with Alembic - Update README with documentation generated with BackendIM... (backend.im)
22 lines
679 B
Python
22 lines
679 B
Python
import os
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Weather Data API"
|
|
|
|
# Database configuration
|
|
DB_DIR = Path("/app") / "storage" / "db"
|
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
# OpenWeatherMap API configuration
|
|
OPENWEATHERMAP_API_KEY: Optional[str] = os.getenv("OPENWEATHERMAP_API_KEY")
|
|
OPENWEATHERMAP_API_URL: str = "https://api.openweathermap.org/data/2.5"
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
|
|
settings = Settings() |