Update app.py
Browse files
app.py
CHANGED
|
@@ -59,22 +59,22 @@ def process_image(input_image):
|
|
| 59 |
|
| 60 |
# --- 3.取得系統狀態的函數 ---
|
| 61 |
# For React Frontend (JSON)
|
| 62 |
-
def
|
| 63 |
return {
|
| 64 |
"cpu": psutil.cpu_percent(interval=None),
|
| 65 |
"ram": psutil.virtual_memory().percent
|
| 66 |
}
|
| 67 |
# For Gradio UI (Visual Markdown)
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
| 79 |
# --- 4. 介面 ---
|
| 80 |
with gr.Blocks(title="去背服務測試") as app:
|
|
|
|
| 59 |
|
| 60 |
# --- 3.取得系統狀態的函數 ---
|
| 61 |
# For React Frontend (JSON)
|
| 62 |
+
def get_system_stats_api():
|
| 63 |
return {
|
| 64 |
"cpu": psutil.cpu_percent(interval=None),
|
| 65 |
"ram": psutil.virtual_memory().percent
|
| 66 |
}
|
| 67 |
# For Gradio UI (Visual Markdown)
|
| 68 |
+
def get_system_stats_ui():
|
| 69 |
+
cpu = psutil.cpu_percent(interval=None)
|
| 70 |
+
ram = psutil.virtual_memory().percent
|
| 71 |
+
return f"""
|
| 72 |
+
## 🖥️ System Status
|
| 73 |
+
| Metric | Usage |
|
| 74 |
+
|--------|-------|
|
| 75 |
+
| **CPU** | {cpu}% |
|
| 76 |
+
| **RAM** | {ram}% |
|
| 77 |
+
"""
|
| 78 |
|
| 79 |
# --- 4. 介面 ---
|
| 80 |
with gr.Blocks(title="去背服務測試") as app:
|