Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -117,8 +117,26 @@ with gr.Blocks(title="Eroha v6.4.5 Dashboard") as demo:
|
|
| 117 |
|
| 118 |
btn.click(fn=lambda x: f"Echo: {x[:200]}", inputs=inp, outputs=out)
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
gr.Markdown("### 📊 Live Metrics (5s refresh)")
|
| 124 |
cpu_box = gr.Number(label="CPU %")
|
|
|
|
| 117 |
|
| 118 |
btn.click(fn=lambda x: f"Echo: {x[:200]}", inputs=inp, outputs=out)
|
| 119 |
|
| 120 |
+
gr.Markdown("### 🩺 System Health Monitor
|
| 121 |
+
|
| 122 |
+
# 🔄 Заменяем Textbox на HTML-индикатор
|
| 123 |
+
with gr.Row():
|
| 124 |
+
with gr.Column(scale=1):
|
| 125 |
+
health_indicator = gr.HTML("<div style='font-size:20px;'>🟡 Checking...</div>")
|
| 126 |
+
|
| 127 |
+
# Асинхронная функция проверки
|
| 128 |
+
async def check_health_ui():
|
| 129 |
+
try:
|
| 130 |
+
async with httpx.AsyncClient(timeout=2) as client:
|
| 131 |
+
resp = await client.get("http://localhost:7860/health")
|
| 132 |
+
if resp.status_code == 200 and resp.json().get("status") == "ok":
|
| 133 |
+
return "<div style='color:lime;font-size:20px;'>🟢 ONLINE</div>"
|
| 134 |
+
except Exception:
|
| 135 |
+
pass
|
| 136 |
+
return "<div style='color:red;font-size:20px;'>🔴 OFFLINE</div>"
|
| 137 |
+
|
| 138 |
+
# Автообновление статуса каждые 5 секунд
|
| 139 |
+
demo.load(check_health_ui, outputs=[health_indicator], every=5)
|
| 140 |
|
| 141 |
gr.Markdown("### 📊 Live Metrics (5s refresh)")
|
| 142 |
cpu_box = gr.Number(label="CPU %")
|