Yermek68 commited on
Commit
1900f6d
Β·
verified Β·
1 Parent(s): bf8157d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py CHANGED
@@ -91,6 +91,42 @@ with gr.Blocks(title="Eroha v6.4.4 Dashboard") as demo:
91
 
92
  demo.load(lambda: (state["cpu"], state["ram"]), outputs=[cpu_box, ram_box], every=5)
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  # ───────────────────────────────
96
  # 5️⃣ Mount Gradio to FastAPI (single port)
 
91
 
92
  demo.load(lambda: (state["cpu"], state["ram"]), outputs=[cpu_box, ram_box], every=5)
93
 
94
+ import httpx
95
+
96
+ # 4️⃣b Health Status Checker
97
+ async def check_health():
98
+ """ΠŸΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° состояния API."""
99
+ try:
100
+ async with httpx.AsyncClient(timeout=2) as client:
101
+ resp = await client.get("http://localhost:7860/health")
102
+ if resp.status_code == 200 and resp.json().get("status") == "ok":
103
+ return "🟒 ONLINE"
104
+ except Exception:
105
+ pass
106
+ return "πŸ”΄ OFFLINE"
107
+
108
+ # ДобавляСм Π² интСрфСйс Gradio
109
+ with gr.Blocks(title="Eroha v6.4.5 Dashboard") as demo:
110
+ gr.Markdown("## βš™οΈ Eroha v6.4.5 – Stable Health Edition")
111
+
112
+ with gr.Row():
113
+ with gr.Column():
114
+ inp = gr.Textbox(label="Prompt")
115
+ btn = gr.Button("Send")
116
+ out = gr.Textbox(label="Response")
117
+
118
+ btn.click(fn=lambda x: f"Echo: {x[:200]}", inputs=inp, outputs=out)
119
+
120
+ gr.Markdown("### 🩺 System Health Monitor")
121
+ health_box = gr.Textbox(label="API Status", interactive=False)
122
+
123
+ gr.Markdown("### πŸ“Š Live Metrics (5s refresh)")
124
+ cpu_box = gr.Number(label="CPU %")
125
+ ram_box = gr.Number(label="RAM %")
126
+
127
+ # Auto-updates
128
+ demo.load(check_health, outputs=[health_box], every=5)
129
+ demo.load(lambda: (state["cpu"], state["ram"]), outputs=[cpu_box, ram_box], every=5)
130
 
131
  # ───────────────────────────────
132
  # 5️⃣ Mount Gradio to FastAPI (single port)