Spaces:
Running
Running
Download config.py from Shadowfilebot/Bot: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/spaces/Shadowfilebot/Bot/resolve/main/config.py
- Command line
-
hf download hf://spaces/Shadowfilebot/Bot/config.py
-
curl -L -o config.py https://huggingface.co/spaces/Shadowfilebot/Bot/resolve/main/config.py
1.84 kB
| """ | |
| Centralized configuration for PanelThTuanIT. | |
| Single Responsibility: all constants and paths live here. | |
| Dependency Inversion: other modules depend on this abstraction, not on each other. | |
| """ | |
| import os | |
| import re | |
| from pathlib import Path | |
| # ── Paths ────────────────────────────────────── | |
| DATA_DIR = Path(os.environ.get("DATA_DIR", "/data/zones")) | |
| ZONES_META = DATA_DIR.parent / "zones_meta.json" | |
| USERS_FILE = DATA_DIR.parent / "users.json" | |
| DOMAINS_FILE = DATA_DIR.parent / "domains.json" | |
| SETTINGS_FILE = DATA_DIR.parent / "settings.json" | |
| REVIEWS_FILE = DATA_DIR.parent / "reviews.json" | |
| JWT_SECRET_FILE = DATA_DIR.parent / ".jwt_secret" | |
| DATA_DIR.mkdir(parents=True, exist_ok=True) | |
| # ── Validation ───────────────────────────────── | |
| ZONE_NAME_PATTERN = re.compile(r"^[a-zA-Z0-9_-]{1,50}$") | |
| # ── Port Limits ──────────────────────────────── | |
| MIN_PORT = 1024 | |
| MAX_PORT = 65535 | |
| # ── Terminal ─────────────────────────────────── | |
| SCROLLBACK_SIZE = 256 * 1024 # 256 KB | |
| # ── Admin API (Optional Cloudflare Worker or Standalone) ── | |
| ADMIN_API_URL = os.environ.get("ADMIN_API_URL", "").strip() | |
| # ── HuggingFace Backup Config ────────────────── | |
| HF_TOKEN = os.environ.get("HF_TOKEN", "").strip() | |
| HF_REPO = os.environ.get("HF_BACKUP_REPO", os.environ.get("HF_REPO", "")).strip() | |
| # ── Backup (local temp dir) ──────────────────── | |
| BACKUP_DIR = DATA_DIR.parent / "backups" | |
| BACKUP_DIR.mkdir(parents=True, exist_ok=True) | |