""" Application Configuration """ import os from datetime import timedelta from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() class Config: """Base configuration""" # Flask SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production') DEBUG = False TESTING = False # Session PERMANENT_SESSION_LIFETIME = timedelta(hours=8) SESSION_COOKIE_SECURE = False SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SAMESITE = 'Lax' # Database DB_HOST = os.getenv('DB_HOST', 'localhost') DB_PORT = int(os.getenv('DB_PORT', 3306)) DB_USER = os.getenv('DB_USER', 'quality_user') DB_PASSWORD = os.getenv('DB_PASSWORD', 'password') DB_NAME = os.getenv('DB_NAME', 'quality_db') # Database pool settings DB_POOL_SIZE = 10 DB_POOL_TIMEOUT = 30 DB_POOL_RECYCLE = 3600 # Application APP_PORT = int(os.getenv('APP_PORT', 8080)) APP_HOST = os.getenv('APP_HOST', '0.0.0.0') # Logging LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO') LOG_DIR = os.getenv('LOG_DIR', './data/logs') # Upload settings MAX_CONTENT_LENGTH = 100 * 1024 * 1024 # 100MB max upload UPLOAD_FOLDER = os.getenv('UPLOAD_FOLDER', './data/uploads') # Ensure directories exist os.makedirs(LOG_DIR, exist_ok=True) os.makedirs(UPLOAD_FOLDER, exist_ok=True) class DevelopmentConfig(Config): """Development configuration""" DEBUG = True TESTING = False class ProductionConfig(Config): """Production configuration""" DEBUG = False TESTING = False SESSION_COOKIE_SECURE = True class TestingConfig(Config): """Testing configuration""" DEBUG = True TESTING = True DB_NAME = 'quality_db_test' # Select configuration based on environment env = os.getenv('FLASK_ENV', 'production') if env == 'development': ConfigClass = DevelopmentConfig elif env == 'testing': ConfigClass = TestingConfig else: ConfigClass = ProductionConfig