import os import secrets # Manually load .env variables if present _env_path = os.path.join(os.path.dirname(__file__), ".env") if os.path.exists(_env_path): try: with open(_env_path, "r") as f: for line in f: line = line.strip() if line and not line.startswith("#") and "=" in line: key, val = line.split("=", 1) os.environ[key.strip()] = val.strip() except Exception: pass class Config: ADMIN_USERNAME = os.getenv("ADMIN_USERNAME") ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD") SECRET_KEY = os.getenv("SECRET_KEY") if not SECRET_KEY: secret_file = os.path.join(os.path.dirname(__file__), ".secret_key") if os.path.exists(secret_file): try: with open(secret_file, "r") as f: SECRET_KEY = f.read().strip() except Exception: SECRET_KEY = "fallback-secret-key-please-change" else: SECRET_KEY = secrets.token_hex(32) try: with open(secret_file, "w") as f: f.write(SECRET_KEY) except Exception: pass