No machines connected
-Waiting for collectors to send metrics...
-diff --git a/ctrl/edge/Dockerfile b/ctrl/edge/Dockerfile index 9e92404..b098374 100644 --- a/ctrl/edge/Dockerfile +++ b/ctrl/edge/Dockerfile @@ -2,9 +2,10 @@ FROM python:3.11-slim WORKDIR /app -RUN pip install --no-cache-dir fastapi uvicorn[standard] websockets +RUN pip install --no-cache-dir fastapi uvicorn[standard] websockets jinja2 COPY edge.py . +COPY templates/ templates/ ENV API_KEY="" ENV LOG_LEVEL=INFO diff --git a/ctrl/edge/edge.py b/ctrl/edge/edge.py index 526b9e4..77aa94c 100644 --- a/ctrl/edge/edge.py +++ b/ctrl/edge/edge.py @@ -4,10 +4,12 @@ import asyncio import json import logging import os -from datetime import datetime +from pathlib import Path from fastapi import FastAPI, Query, WebSocket, WebSocketDisconnect +from fastapi.requests import Request from fastapi.responses import HTMLResponse +from fastapi.templating import Jinja2Templates # Configuration API_KEY = os.environ.get("API_KEY", "") @@ -23,367 +25,19 @@ log = logging.getLogger("gateway") app = FastAPI(title="sysmonstm") +# Templates +templates_path = Path(__file__).parent / "templates" +templates = Jinja2Templates(directory=str(templates_path)) + # Store connected websockets connections: list[WebSocket] = [] # Store latest metrics from collectors machines: dict = {} -HTML = """ - - -
- - -Waiting for collectors to send metrics...
-Waiting for collectors to send metrics...
+