File size: 1,185 Bytes
58b2f9d
 
dd667a6
 
36a8571
 
 
 
 
 
 
dd667a6
 
58b2f9d
 
dd667a6
 
 
58b2f9d
 
 
 
cde8e2f
 
58b2f9d
dd667a6
58b2f9d
 
 
 
 
 
 
dd667a6
58b2f9d
 
 
 
 
 
 
 
 
cde8e2f
 
dd667a6
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import requests
import gradio as gr

SPACES = {
    "Space One": "https://test.hf.space",
    "Space Two": "https://hub.hf.space",
    "Space Three": "https://Blogger-Toolkit.hf.space",
    "Space Four": "https://blogger-source-downloader",
    "Space Five": "https://Heavy-Tools",
    "Space Six": "https://test.hf.space",
    "Space Seven": "https://test.hf.space",
}

def fetch():
    rows = []
    for name, url in SPACES.items():
        try:
            r = requests.get(url, timeout=3)
            j = r.json()
            rows.append([
                name,
                "🟢 RUNNING",
                int(j.get("cpu", 0)),
                int(j.get("ram", 0))
            ])
        except:
            rows.append([
                name,
                "⚫ SLEEPING",
                0,
                0
            ])
    return rows

with gr.Blocks() as demo:
    gr.Markdown("## 🚀 Hugging Face Spaces Monitor")

    table = gr.Dataframe(
        headers=["Space", "Status", "CPU %", "RAM %"],
        datatype=["str", "str", "number", "number"],
        interactive=False
    )

    timer = gr.Timer(value=30)
    timer.tick(fetch, outputs=table)

demo.launch()