Spaces:
Running
Running
Download src/dashboard/network_settings.py from ThomasHeisig/MHRN-Space: direct link, hf CLI and curl.
- Browser
- Download file 2.76 kB
-
https://huggingface.co/spaces/ThomasHeisig/MHRN-Space/resolve/main/src/dashboard/network_settings.py
- Command line
-
hf download hf://spaces/ThomasHeisig/MHRN-Space/src/dashboard/network_settings.py
-
curl -L -o network_settings.py https://huggingface.co/spaces/ThomasHeisig/MHRN-Space/resolve/main/src/dashboard/network_settings.py
2.76 kB
| """Central network settings for the MHRN dashboard. | |
| All components (launcher, server, start scripts, Hugging Face config) | |
| read their default host, port and LAN policy from this single module. | |
| Change values here to reconfigure the entire stack. | |
| """ | |
| from __future__ import annotations | |
| # --------------------------------------------------------------------------- | |
| # Dashboard HTTP server | |
| # --------------------------------------------------------------------------- | |
| DASHBOARD_HOST: str = "127.0.0.1" | |
| """Default bind address for direct Python dashboard startup.""" | |
| DASHBOARD_LAN_HOST: str = "0.0.0.0" # nosec B104 - trusted-LAN wrapper default | |
| """Trusted-LAN bind address used by the Windows convenience wrappers. | |
| The Windows launchers intentionally expose the dashboard to the host's private | |
| network by default. Direct Python startup remains loopback-only unless the user | |
| passes an explicit host. | |
| """ | |
| DASHBOARD_PORT: int = 8767 | |
| """Default TCP port for the dashboard HTTP server.""" | |
| # --------------------------------------------------------------------------- | |
| # Public / Internet policy | |
| # --------------------------------------------------------------------------- | |
| ALLOW_PUBLIC_DEPLOYMENT: bool = False | |
| """Whether the dashboard is allowed to bind to a public interface. | |
| Set this to ``True`` only when a proper reverse proxy, TLS, authentication, | |
| logging and privacy notice are in place. The dashboard exposes operator, | |
| research and file-management endpoints without built-in access control. | |
| """ | |
| PUBLIC_DEPLOYMENT_NOTE: str = ( | |
| "The dashboard exposes operator, research and file-management capabilities. " | |
| "Do not expose it directly to the public Internet. For trusted-LAN use, " | |
| f"restrict TCP port {DASHBOARD_PORT} to the intended private network." | |
| ) | |
| """Safety note displayed in the README and referenced in deployment docs.""" | |
| # --------------------------------------------------------------------------- | |
| # Hugging Face Space | |
| # --------------------------------------------------------------------------- | |
| HF_SPACE_PORT: int = DASHBOARD_PORT | |
| """Port used inside the Hugging Face Docker Space (must match EXPOSE).""" | |
| HF_SPACE_HOST: str = "0.0.0.0" # nosec B104 - required container bind for HF Spaces | |
| """Host used inside the Hugging Face Space container.""" | |
| # --------------------------------------------------------------------------- | |
| # Convenience accessors | |
| # --------------------------------------------------------------------------- | |
| def dashboard_local_url() -> str: | |
| """Return the loopback URL of the dashboard.""" | |
| return f"http://127.0.0.1:{DASHBOARD_PORT}" | |
| def dashboard_bind_spec() -> str: | |
| """Return the ``host:port`` string used for bind / firewall docs.""" | |
| return f"{DASHBOARD_HOST}:{DASHBOARD_PORT}" | |