Spaces:
Sleeping
Sleeping
Download backend/visual_notebook/config.py from Sid-WC121/visual-notebook: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/Sid-WC121/visual-notebook/resolve/main/backend/visual_notebook/config.py
- Command line
-
hf download hf://spaces/Sid-WC121/visual-notebook/backend/visual_notebook/config.py
-
curl -L -o config.py https://huggingface.co/spaces/Sid-WC121/visual-notebook/resolve/main/backend/visual_notebook/config.py
1.38 kB
| """Application settings loaded from environment variables.""" | |
| from __future__ import annotations | |
| import os | |
| from dataclasses import dataclass, field | |
| def _parse_cors_origins() -> list[str]: | |
| """Parse CORS_ORIGINS env var into a list of origins. | |
| Handles these patterns: | |
| CORS_ORIGINS=* → ["*"] | |
| CORS_ORIGINS=http://localhost:5173,http://localhost:3000 → split by comma | |
| CORS_ORIGINS not set → sensible dev defaults | |
| """ | |
| raw = os.getenv("CORS_ORIGINS", "").strip() | |
| if raw == "*": | |
| return ["*"] | |
| if raw: | |
| return [origin.strip() for origin in raw.split(",") if origin.strip()] | |
| # Default: local development origins | |
| return ["http://localhost:5173", "http://localhost:3000"] | |
| class Settings: | |
| data_dir: str = os.getenv("DATA_DIR", "datasets") | |
| checkpoint_dir: str = os.getenv("CHECKPOINT_DIR", "checkpoints") | |
| max_upload_size: int = int(os.getenv("MAX_UPLOAD_SIZE", str(500 * 1024 * 1024))) | |
| preview_rows: int = int(os.getenv("PREVIEW_ROWS", "50")) | |
| sample_rows: int = int(os.getenv("SAMPLE_ROWS", "10000")) | |
| cors_origins: list[str] = field( | |
| default_factory=lambda: _parse_cors_origins() | |
| ) | |
| host: str = os.getenv("HOST", "0.0.0.0") | |
| port: int = int(os.getenv("PORT", "8000")) | |
| settings = Settings() | |