deploymate / app /core /config.py
shakauthossain's picture
V2.0.0
2df0cf9 verified
"""
Core configuration for the DevOps Toolkit API.
"""
import os
from pathlib import Path
from typing import List
class Settings:
"""Application settings loaded from environment variables."""
def __init__(self):
# Server settings
self.host: str = os.getenv("HOST", "0.0.0.0")
self.port: int = int(os.getenv("PORT", 7860))
self.debug: bool = os.getenv("DEBUG", "false").lower() == "true"
# Security settings
self.allowed_origins: List[str] = os.getenv("ALLOWED_ORIGINS", "*").split(",")
self.rate_limit_requests: int = int(os.getenv("RATE_LIMIT_REQUESTS", 10))
# Logging settings
self.log_level: str = os.getenv("LOG_LEVEL", "INFO")
# Path settings
self.base_dir: Path = Path(__file__).parent.parent
self.templates_dir: Path = self.base_dir / "templates"
self.generated_dir: Path = self.base_dir.parent / "generated"
self.logs_dir: Path = self.base_dir.parent / "logs"
# Ensure directories exist
self.templates_dir.mkdir(exist_ok=True)
self.generated_dir.mkdir(exist_ok=True)
self.logs_dir.mkdir(exist_ok=True)
# Global settings instance
settings = Settings()