add web.js and also change how does the web html look

This commit is contained in:
2026-04-16 18:03:54 +02:00
parent d0423346f0
commit e1acdb9e60
3 changed files with 432 additions and 423 deletions
+9 -1
View File
@@ -113,7 +113,7 @@ def websocket_server_process(shared_data: dict, imc_q: multiprocessing.Queue, ws
await websocket.close(1001, "")
clients.discard(websocket)
async def process_request(websocket: ServerConnection, request: Request):
if request.path == "/" and (file := Path(__file__, "..", "web.html").resolve()).exists():
if request.path == "/" and (file := Path(__file__, "..", "web.html")).exists():
data = file.read_bytes()
return Response(
200,
@@ -121,6 +121,14 @@ def websocket_server_process(shared_data: dict, imc_q: multiprocessing.Queue, ws
Headers([("Content-Type", "text/html"), ("Content-Length", f"{len(data)}")]),
data
)
if request.path == "/web.js" and (file := Path(__file__, "..", "web.js")).exists():
data = file.read_bytes()
return Response(
200,
"OK",
Headers([("Content-Type", "text/javascript"), ("Content-Length", f"{len(data)}")]),
data
)
if request.path == "/ws":
if not "upgrade" in request.headers.get("Connection", "").lower():
return Response(