config.py 959 B

12345678910111213141516171819202122232425262728293031323334
  1. from pathlib import Path
  2. from pydantic_settings import BaseSettings
  3. class Settings(BaseSettings):
  4. app_name: str = "BambuTrack"
  5. debug: bool = False # Default to production mode
  6. # Paths
  7. base_dir: Path = Path(__file__).resolve().parent.parent.parent.parent
  8. archive_dir: Path = base_dir / "archive"
  9. static_dir: Path = base_dir / "static"
  10. log_dir: Path = base_dir / "logs"
  11. database_url: str = f"sqlite+aiosqlite:///{base_dir}/bambutrack.db"
  12. # Logging
  13. log_level: str = "INFO" # Override with LOG_LEVEL env var or DEBUG=true
  14. log_to_file: bool = True # Set to false to disable file logging
  15. # API
  16. api_prefix: str = "/api/v1"
  17. class Config:
  18. env_file = ".env"
  19. env_file_encoding = "utf-8"
  20. settings = Settings()
  21. # Ensure directories exist
  22. settings.archive_dir.mkdir(exist_ok=True)
  23. settings.static_dir.mkdir(exist_ok=True)
  24. if settings.log_to_file:
  25. settings.log_dir.mkdir(exist_ok=True)