diff --git a/muxplex/main.py b/muxplex/main.py index 7e30a70..505e27e 100644 --- a/muxplex/main.py +++ b/muxplex/main.py @@ -14,6 +14,7 @@ import logging import os import pathlib import pwd +import socket import subprocess import sys import time @@ -282,11 +283,15 @@ class CreateSessionPayload(BaseModel): # --------------------------------------------------------------------------- -# Frontend directory +# Frontend directory + hostname # --------------------------------------------------------------------------- _FRONTEND_DIR = pathlib.Path(__file__).parent / "frontend" +# Short hostname (no domain) injected into page titles so browser tabs show +# which machine each muxplex instance is running on. +_HOSTNAME = socket.gethostname().split(".")[0] + # --------------------------------------------------------------------------- # Routes @@ -564,6 +569,18 @@ async def terminal_ws_proxy(websocket: WebSocket) -> None: # --------------------------------------------------------------------------- +@app.get("/", response_class=HTMLResponse) +@app.get("/index.html", response_class=HTMLResponse) +async def index_page(): + """Serve index.html with hostname injected into the page title.""" + html = (_FRONTEND_DIR / "index.html").read_text() + html = html.replace( + "