Spaces:
Runtime error
Runtime error
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """Configuration loader with sane defaults and fallback behavior.""" | |
| import os | |
| import yaml | |
| from typing import Any, Dict | |
| def load_config(path: str = "config.yaml") -> Dict[str, Any]: | |
| if not os.path.exists(path): | |
| print(f"⚠️ Config file missing at {path}, using defaults.") | |
| return { | |
| "app": {"name": "MyApp", "debug": True}, | |
| "server": {"host": "0.0.0.0", "port": 8000}, | |
| } | |
| with open(path, "r", encoding="utf-8") as f: | |
| return yaml.safe_load(f) or {} | |