Update app.py
Browse files
app.py
CHANGED
|
@@ -1,47 +1,47 @@
|
|
| 1 |
-
import requests
|
|
|
|
|
|
|
| 2 |
|
| 3 |
SPACES = {
|
| 4 |
-
"Space One": "https://
|
| 5 |
-
"Space Two": "https://
|
| 6 |
-
"Space Three": "https://
|
| 7 |
"Space Four": "https://space-four.hf.space",
|
| 8 |
"Space Five": "https://space-five.hf.space",
|
| 9 |
"Space Six": "https://space-six.hf.space",
|
| 10 |
"Space Seven": "https://space-seven.hf.space",
|
| 11 |
}
|
| 12 |
|
| 13 |
-
def
|
| 14 |
-
|
| 15 |
for name, url in SPACES.items():
|
| 16 |
try:
|
| 17 |
r = requests.get(url, timeout=3)
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
"RAM MB": j["ram_mb"]
|
| 26 |
-
})
|
| 27 |
-
else:
|
| 28 |
-
raise Exception()
|
| 29 |
except:
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
"
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
return data
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
demo.launch()
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import time
|
| 4 |
|
| 5 |
SPACES = {
|
| 6 |
+
"Space One": "https://lexicalspace-test.hf.space",
|
| 7 |
+
"Space Two": "https://lexicalspace-Blogger-Toolkit.hf.space",
|
| 8 |
+
"Space Three": "https://lexicalspace-.hf.space",
|
| 9 |
"Space Four": "https://space-four.hf.space",
|
| 10 |
"Space Five": "https://space-five.hf.space",
|
| 11 |
"Space Six": "https://space-six.hf.space",
|
| 12 |
"Space Seven": "https://space-seven.hf.space",
|
| 13 |
}
|
| 14 |
|
| 15 |
+
def fetch():
|
| 16 |
+
rows = []
|
| 17 |
for name, url in SPACES.items():
|
| 18 |
try:
|
| 19 |
r = requests.get(url, timeout=3)
|
| 20 |
+
j = r.json()
|
| 21 |
+
rows.append([
|
| 22 |
+
name,
|
| 23 |
+
"🟢 RUNNING",
|
| 24 |
+
j["cpu"],
|
| 25 |
+
j["ram"]
|
| 26 |
+
])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
except:
|
| 28 |
+
rows.append([
|
| 29 |
+
name,
|
| 30 |
+
"⚫ SLEEPING",
|
| 31 |
+
0,
|
| 32 |
+
0
|
| 33 |
+
])
|
| 34 |
+
return rows
|
|
|
|
| 35 |
|
| 36 |
+
with gr.Blocks() as demo:
|
| 37 |
+
gr.Markdown("## 🚀 Hugging Face Spaces Monitor")
|
| 38 |
+
|
| 39 |
+
table = gr.Dataframe(
|
| 40 |
+
headers=["Space", "Status", "CPU %", "RAM %"],
|
| 41 |
+
datatype=["str", "str", "number", "number"],
|
| 42 |
+
interactive=False
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
demo.load(fetch, None, table, every=30)
|
| 46 |
|
| 47 |
demo.launch()
|