Spaces:
Running
Running
File size: 1,081 Bytes
7553a70 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | """Helpers for presenting local admin URLs."""
from __future__ import annotations
from config.settings import Settings
def _browser_host_for_local_urls(settings: Settings) -> str:
"""Host fragment for URLs shown to humans on the same machine as the server."""
host = settings.host.strip() if settings.host else "127.0.0.1"
if host in {"0.0.0.0", "::", "[::]"}:
host = "127.0.0.1"
if ":" in host and not host.startswith("["):
host = f"[{host}]"
return host
def local_proxy_root_url(settings: Settings) -> str:
"""Return the proxy root URL (no path) for clients on the same machine."""
return f"http://{_browser_host_for_local_urls(settings)}:{settings.port}"
def local_admin_url(settings: Settings) -> str:
"""Return a browser-friendly URL for the localhost-only admin UI."""
return f"{local_proxy_root_url(settings)}/admin"
def admin_launch_message(settings: Settings) -> str:
"""Return the startup message shown by supported launch commands."""
return f"Admin UI: {local_admin_url(settings)} (local-only)"
|