diff --git a/src/server.py b/src/server.py index dda0d22..599267a 100644 --- a/src/server.py +++ b/src/server.py @@ -2,6 +2,7 @@ from __future__ import annotations import asyncio import secrets +import socket from contextlib import asynccontextmanager from pathlib import Path from typing import Any @@ -89,6 +90,7 @@ def create_app(config: AppConfig | None = None) -> FastAPI: app.state.db = db app.state.ws_hub = ws_hub app.state.manager = manager + device_hostname = socket.gethostname() def _extract_token( authorization: str | None, @@ -196,7 +198,7 @@ def create_app(config: AppConfig | None = None) -> FastAPI: if not app_config.disable_ui: @app.get("/", response_class=HTMLResponse) def ui_root() -> str: - return monitoring_page_html() + return monitoring_page_html(device_hostname=device_hostname) @app.websocket("/ws") async def ws_endpoint(websocket: WebSocket, token: str = Query(default="")) -> None: diff --git a/src/ui.py b/src/ui.py index df93730..a4bc53f 100644 --- a/src/ui.py +++ b/src/ui.py @@ -1,7 +1,9 @@ from __future__ import annotations +from html import escape -def monitoring_page_html() -> str: +def monitoring_page_html(device_hostname: str = "") -> str: + host_suffix = f" ({escape(device_hostname)})" if device_hostname else "" return """
@@ -14,7 +16,7 @@ def monitoring_page_html() -> str:Read-only monitoring for active and historical tasks.