34 lines
959 B
Python
34 lines
959 B
Python
import os
|
|
from pathlib import Path
|
|
from typing import ClassVar
|
|
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: ClassVar[Path] = 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) |