Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -117,14 +117,14 @@ 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 |
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:
|
|
@@ -135,16 +135,16 @@ async def check_health_ui():
|
|
| 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 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
demo.load(lambda: (state["cpu"], state["ram"]), outputs=[cpu_box, ram_box], every=5)
|
| 148 |
|
| 149 |
# ───────────────────────────────
|
| 150 |
# 5️⃣ Mount Gradio to FastAPI (single port)
|
|
|
|
| 117 |
|
| 118 |
btn.click(fn=lambda x: f"Echo: {x[:200]}", inputs=inp, outputs=out)
|
| 119 |
|
| 120 |
+
# 🩺 System Health Monitor
|
| 121 |
gr.Markdown("### 🩺 System Health Monitor")
|
| 122 |
|
|
|
|
| 123 |
with gr.Row():
|
| 124 |
with gr.Column(scale=1):
|
| 125 |
health_indicator = gr.HTML("<div style='font-size:20px;'>🟡 Checking...</div>")
|
| 126 |
|
| 127 |
+
# Асинхронная функция проверки состояния API
|
| 128 |
async def check_health_ui():
|
| 129 |
try:
|
| 130 |
async with httpx.AsyncClient(timeout=2) as client:
|
|
|
|
| 135 |
pass
|
| 136 |
return "<div style='color:red;font-size:20px;'>🔴 OFFLINE</div>"
|
| 137 |
|
| 138 |
+
# Автообновление статуса API каждые 5 секунд
|
| 139 |
demo.load(check_health_ui, outputs=[health_indicator], every=5)
|
| 140 |
|
| 141 |
+
# 📊 Live Metrics (5s refresh)
|
| 142 |
+
gr.Markdown("### 📊 Live Metrics (5s refresh)")
|
| 143 |
+
cpu_box = gr.Number(label="CPU %")
|
| 144 |
+
ram_box = gr.Number(label="RAM %")
|
| 145 |
|
| 146 |
+
# Автообновление метрик
|
| 147 |
+
demo.load(lambda: (state["cpu"], state["ram"]), outputs=[cpu_box, ram_box], every=5)
|
|
|
|
| 148 |
|
| 149 |
# ───────────────────────────────
|
| 150 |
# 5️⃣ Mount Gradio to FastAPI (single port)
|