diff --git a/backend/app/core/config.py b/backend/app/core/config.py index 02f86d4..fde2bd5 100644 --- a/backend/app/core/config.py +++ b/backend/app/core/config.py @@ -5,16 +5,17 @@ This module handles environment variable loading and provides default values for configuration settings. """ +import ast +import json import os from pathlib import Path -from typing import Optional, List -import json -import ast +from typing import List, Optional try: from dotenv import load_dotenv + # Try to load .env file from project root - env_path = Path(__file__).parent.parent.parent.parent / '.env' + env_path = Path(__file__).parent.parent.parent.parent / ".env" if env_path.exists(): load_dotenv(env_path) except ImportError: @@ -25,7 +26,7 @@ except ImportError: class Settings: """Application settings loaded from environment variables.""" - def __init__(self): + def __init__(self) -> None: """Initialize settings from environment variables.""" # Application info self.app_name: str = os.getenv("APP_NAME", "UnitForge") @@ -53,10 +54,15 @@ class Settings: self.log_level: str = os.getenv("LOG_LEVEL", "info") # Server configuration - self.host: str = os.getenv("HOST", "0.0.0.0") + self.host: str = os.getenv("HOST", "0.0.0.0") # nosec B104 self.port: int = int(os.getenv("PORT", "8000")) self.debug: bool = os.getenv("DEBUG", "").lower() in ("true", "1", "yes", "on") - self.reload: bool = os.getenv("RELOAD", "").lower() in ("true", "1", "yes", "on") + self.reload: bool = os.getenv("RELOAD", "").lower() in ( + "true", + "1", + "yes", + "on", + ) self.workers: int = int(os.getenv("WORKERS", "4")) # API configuration @@ -77,7 +83,7 @@ class Settings: self.max_upload_size: int = int(os.getenv("MAX_UPLOAD_SIZE", "1048576")) self.allowed_extensions: List[str] = self._parse_list( "ALLOWED_EXTENSIONS", - [".service", ".timer", ".socket", ".mount", ".target", ".path"] + [".service", ".timer", ".socket", ".mount", ".target", ".path"], ) # Template settings @@ -92,9 +98,15 @@ class Settings: # Feature flags self.enable_api_metrics: bool = self._get_bool("ENABLE_API_METRICS", False) - self.enable_request_logging: bool = self._get_bool("ENABLE_REQUEST_LOGGING", True) - self.enable_template_caching: bool = self._get_bool("ENABLE_TEMPLATE_CACHING", True) - self.enable_validation_caching: bool = self._get_bool("ENABLE_VALIDATION_CACHING", True) + self.enable_request_logging: bool = self._get_bool( + "ENABLE_REQUEST_LOGGING", True + ) + self.enable_template_caching: bool = self._get_bool( + "ENABLE_TEMPLATE_CACHING", True + ) + self.enable_validation_caching: bool = self._get_bool( + "ENABLE_VALIDATION_CACHING", True + ) # Performance settings self.request_timeout: int = int(os.getenv("REQUEST_TIMEOUT", "30")) @@ -121,8 +133,12 @@ class Settings: # Template generation defaults self.default_user: str = os.getenv("DEFAULT_USER", "www-data") self.default_group: str = os.getenv("DEFAULT_GROUP", "www-data") - self.default_restart_policy: str = os.getenv("DEFAULT_RESTART_POLICY", "on-failure") - self.default_wanted_by: str = os.getenv("DEFAULT_WANTED_BY", "multi-user.target") + self.default_restart_policy: str = os.getenv( + "DEFAULT_RESTART_POLICY", "on-failure" + ) + self.default_wanted_by: str = os.getenv( + "DEFAULT_WANTED_BY", "multi-user.target" + ) # Security headers self.security_headers: bool = self._get_bool("SECURITY_HEADERS", True) @@ -192,6 +208,7 @@ class Settings: if parsed: return parsed except Exception: + # Fall back to comma-separated parsing if JSON/literal parsing fails pass # Fall back to comma-separated values diff --git a/frontend/static/css/style.css b/frontend/static/css/style.css index a89878c..f884f01 100644 --- a/frontend/static/css/style.css +++ b/frontend/static/css/style.css @@ -508,15 +508,15 @@ footer.bg-dark .text-muted { } .form-control { - background-color: #2d3748; + background-color: var(--bg-secondary); border-color: #4a5568; - color: #f7fafc; + color: #333; } .form-control:focus { - background-color: #2d3748; + background-color: var(--bg-secondary); border-color: var(--primary-color); - color: #f7fafc; + color: #333; } }