Spaces:
Paused
Paused
Serve Hermes dashboard under app route
Browse filesFiles changed (2)
- README.md+1-1
- health-server.js+48-6
127 unmodified lines128129130131132133134127 unmodified lines| `/` | HuggingMess dashboard || `/health` | Health check for HF and UptimeRobot || `/status` | JSON status || `/dashboard/` | Proxied Hermes dashboard || `/v1/models` | Proxied Hermes OpenAI-compatible API server || `/telegram` | Telegram webhook endpoint |127 unmodified lines128129130131132133134127 unmodified lines| `/` | HuggingMess dashboard || `/health` | Health check for HF and UptimeRobot || `/status` | JSON status || `/app/` | Proxied Hermes dashboard/app || `/v1/models` | Proxied Hermes OpenAI-compatible API server || `/telegram` | Telegram webhook endpoint |
10 unmodified lines11121314151652 unmodified lines69707172737439 unmodified lines11411511611711811912057 unmodified lines17817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021110 unmodified linesconst GATEWAY_HOST = "127.0.0.1";const startTime = Date.now();const API_SERVER_KEY = process.env.API_SERVER_KEY || "";const SYNC_STATUS_FILE = "/tmp/huggingmess-sync-status.json";const UPTIMEROBOT_STATUS_FILE = "/tmp/huggingmess-uptimerobot-status.json";52 unmodified linesreq.pipe(proxy);}function formatUptime(ms) {const total = Math.floor(ms / 1000);const days = Math.floor(total / 86400);39 unmodified linesfunction renderDashboard(data) {const syncStatus = String(data.backup?.status || "unknown").toUpperCase();const dashboardLink = data.dashboard ? `<a class="button" href="/dashboard/">Open Hermes Dashboard</a>` : "";const apiLink = data.gateway ? `<a class="button secondary" href="/v1/models">API Models</a>` : "";const keepAlive = data.uptimerobot?.configured? `UptimeRobot is monitoring <code>${data.uptimerobot.url}</code>.`57 unmodified linesconst parsed = new URL(req.url, "http://localhost");const path = parsed.pathname;if (path === "/health" || path === "/dashboard/health") {const data = await statusPayload();res.writeHead(data.ok ? 200 : 503, { "content-type": "application/json" });res.end(JSON.stringify({ ok: data.ok, gateway: data.gateway, uptime: data.uptime }));return;}if (path === "/status" || path === "/dashboard/status") {const data = await statusPayload();res.writeHead(200, { "content-type": "application/json" });res.end(JSON.stringify(data, null, 2));return;}if (path === "/" || path === "/dashboard") {const data = await statusPayload();res.writeHead(200, { "content-type": "text/html; charset=utf-8" });res.end(renderDashboard(data));return;}if (path === "/telegram" || path.startsWith("/telegram/")) {proxyRequest(req, res, TELEGRAM_WEBHOOK_PORT);return;}if (path === "/dashboard/" || path.startsWith("/dashboard/")) {proxyRequest(req, res, DASHBOARD_PORT, (p) => p.replace(/^\/dashboard/, "") || "/");return;}10 unmodified lines1112131415161752 unmodified lines707172737475767778798039 unmodified lines12012112212312412512657 unmodified lines18418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225310 unmodified linesconst GATEWAY_HOST = "127.0.0.1";const startTime = Date.now();const API_SERVER_KEY = process.env.API_SERVER_KEY || "";const APP_BASE = "/app";const SYNC_STATUS_FILE = "/tmp/huggingmess-sync-status.json";const UPTIMEROBOT_STATUS_FILE = "/tmp/huggingmess-uptimerobot-status.json";52 unmodified linesreq.pipe(proxy);}function redirect(res, location, statusCode = 302) {res.writeHead(statusCode, { location });res.end();}function formatUptime(ms) {const total = Math.floor(ms / 1000);const days = Math.floor(total / 86400);39 unmodified linesfunction renderDashboard(data) {const syncStatus = String(data.backup?.status || "unknown").toUpperCase();const dashboardLink = data.dashboard ? `<a class="button" href="${APP_BASE}/">Open Hermes App</a>` : "";const apiLink = data.gateway ? `<a class="button secondary" href="/v1/models">API Models</a>` : "";const keepAlive = data.uptimerobot?.configured? `UptimeRobot is monitoring <code>${data.uptimerobot.url}</code>.`57 unmodified linesconst parsed = new URL(req.url, "http://localhost");const path = parsed.pathname;if (path === "/health" || path === `${APP_BASE}/health`) {const data = await statusPayload();res.writeHead(data.ok ? 200 : 503, { "content-type": "application/json" });res.end(JSON.stringify({ ok: data.ok, gateway: data.gateway, uptime: data.uptime }));return;}if (path === "/status" || path === `${APP_BASE}/status`) {const data = await statusPayload();res.writeHead(200, { "content-type": "application/json" });res.end(JSON.stringify(data, null, 2));return;}if (path === "/") {const data = await statusPayload();res.writeHead(200, { "content-type": "text/html; charset=utf-8" });res.end(renderDashboard(data));return;}if (path === "/dashboard" || path === "/dashboard/") {redirect(res, `${APP_BASE}/${parsed.search}`);return;}if (path === "/telegram" || path.startsWith("/telegram/")) {proxyRequest(req, res, TELEGRAM_WEBHOOK_PORT);return;}if (path === APP_BASE || path.startsWith(`${APP_BASE}/`)) {proxyRequest(req, res, DASHBOARD_PORT, (p) => p.replace(/^\/app/, "") || "/");return;}if (path === "/favicon.ico" ||path.startsWith("/assets/") ||path.startsWith("/api/") ||path.startsWith("/dashboard-plugins/") ||path.startsWith("/ds-assets/")) {proxyRequest(req, res, DASHBOARD_PORT);return;}if (["/analytics","/chat","/config","/cron","/docs","/env","/logs","/models","/plugins","/profiles","/sessions","/skills",].some((route) => path === route || path.startsWith(`${route}/`))) {redirect(res, `${APP_BASE}${path}${parsed.search}`);return;}
README.md+1-1
health-server.js+48-6