favicon
This commit is contained in:
@@ -2733,6 +2733,8 @@ class _TrackerHandler(http.server.BaseHTTPRequestHandler):
|
||||
self._handle_registry_wallets()
|
||||
elif parsed.path in ("/dashboard", "/dashboard/"):
|
||||
self._handle_dashboard()
|
||||
elif parsed.path in ("/favicon.svg", "/favicon.ico"):
|
||||
self._handle_favicon()
|
||||
elif parsed.path == "/v1/health":
|
||||
self._send_json(200, {"status": "ok"})
|
||||
else:
|
||||
@@ -4302,14 +4304,20 @@ class _TrackerHandler(http.server.BaseHTTPRequestHandler):
|
||||
def _handle_dashboard(self):
|
||||
"""Serve the read-only web dashboard (US-035). Any tracker in the
|
||||
mesh — leader or follower — serves it from its replicated state."""
|
||||
self._serve_package_asset("dashboard.html", "text/html; charset=utf-8")
|
||||
|
||||
def _handle_favicon(self) -> None:
|
||||
"""Serve the dashboard favicon (SVG; ICO path aliases the same asset)."""
|
||||
self._serve_package_asset("favicon.svg", "image/svg+xml")
|
||||
|
||||
def _serve_package_asset(self, filename: str, content_type: str) -> None:
|
||||
try:
|
||||
html = files("meshnet_tracker").joinpath("dashboard.html").read_text()
|
||||
body = files("meshnet_tracker").joinpath(filename).read_bytes()
|
||||
except (FileNotFoundError, OSError):
|
||||
self._send_json(404, {"error": "dashboard asset missing"})
|
||||
self._send_json(404, {"error": f"{filename} missing"})
|
||||
return
|
||||
body = html.encode()
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/html; charset=utf-8")
|
||||
self.send_header("Content-Type", content_type)
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user