From 263c66aedde37af6e21a112770f2df67f4a82cdb Mon Sep 17 00:00:00 2001 From: alpha nerd Date: Fri, 10 Apr 2026 17:29:43 +0200 Subject: [PATCH] feat: add hostname to dashboard --- router.py | 12 ++++++++++-- static/index.html | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/router.py b/router.py index 2f27d94..e780a56 100644 --- a/router.py +++ b/router.py @@ -6,7 +6,7 @@ version: 0.7 license: AGPL """ # ------------------------------------------------------------- -import orjson, time, asyncio, yaml, ollama, openai, os, re, aiohttp, ssl, random, base64, io, enhance, secrets, math +import orjson, time, asyncio, yaml, ollama, openai, os, re, aiohttp, ssl, random, base64, io, enhance, secrets, math, socket try: import truststore; truststore.inject_into_ssl() except ImportError: @@ -3776,7 +3776,15 @@ async def health_proxy(request: Request): return JSONResponse(content=response_payload, status_code=http_status) # ------------------------------------------------------------- -# 27. SSE route for usage broadcasts +# 27. Hostname endpoint +# ------------------------------------------------------------- +@app.get("/api/hostname") +async def get_hostname(): + """Return the hostname of the machine running the router.""" + return JSONResponse(content={"hostname": socket.gethostname()}) + +# ------------------------------------------------------------- +# 28. SSE route for usage broadcasts # ------------------------------------------------------------- @app.get("/api/usage-stream") async def usage_stream(request: Request): diff --git a/static/index.html b/static/index.html index e53e629..419d7bb 100644 --- a/static/index.html +++ b/static/index.html @@ -344,6 +344,7 @@

Router Dashboard

+
@@ -1418,6 +1419,11 @@ function initStatsChart(timeSeriesData, endpointDistribution) {