Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
import logging
|
|
|
|
|
4 |
|
5 |
# ๋ก๊น
์ค์
|
6 |
logging.basicConfig(level=logging.INFO)
|
@@ -72,6 +74,7 @@ TARGETS = [
|
|
72 |
{"name": "[HUGPU] ", "url": "https://.hf.space"},
|
73 |
]
|
74 |
|
|
|
75 |
# URL ์ํ ํ์ธ ํจ์
|
76 |
def check_url_status(url):
|
77 |
try:
|
@@ -94,6 +97,13 @@ def update_status():
|
|
94 |
status_html += f'<span class="status-button status-{status_class}">{target["name"]}: {status}</span>'
|
95 |
return status_html
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
# Gradio ์ธํฐํ์ด์ค ์ค์
|
98 |
def create_dashboard():
|
99 |
with gr.Blocks(css=css) as app:
|
@@ -106,11 +116,11 @@ def create_dashboard():
|
|
106 |
refresh_button = gr.Button("์ํ ์๋ก๊ณ ์นจ")
|
107 |
refresh_button.click(fn=update_status, outputs=status_html)
|
108 |
|
109 |
-
# 10์ด๋ง๋ค ์๋์ผ๋ก ์ํ ์
๋ฐ์ดํธ
|
110 |
-
status_html.update(every=10, inputs=None, outputs=status_html)
|
111 |
-
|
112 |
# ์ด๊ธฐ ์ํ ์
๋ฐ์ดํธ
|
113 |
app.load(fn=update_status, outputs=status_html)
|
|
|
|
|
|
|
114 |
|
115 |
return app
|
116 |
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
import logging
|
4 |
+
import threading
|
5 |
+
import time
|
6 |
|
7 |
# ๋ก๊น
์ค์
|
8 |
logging.basicConfig(level=logging.INFO)
|
|
|
74 |
{"name": "[HUGPU] ", "url": "https://.hf.space"},
|
75 |
]
|
76 |
|
77 |
+
|
78 |
# URL ์ํ ํ์ธ ํจ์
|
79 |
def check_url_status(url):
|
80 |
try:
|
|
|
97 |
status_html += f'<span class="status-button status-{status_class}">{target["name"]}: {status}</span>'
|
98 |
return status_html
|
99 |
|
100 |
+
# ์ฃผ๊ธฐ์ ์
๋ฐ์ดํธ๋ฅผ ์ํ ํจ์
|
101 |
+
def periodic_update(status_html):
|
102 |
+
while True:
|
103 |
+
time.sleep(10) # 10์ด ๋๊ธฐ
|
104 |
+
new_status = update_status()
|
105 |
+
status_html.update(value=new_status)
|
106 |
+
|
107 |
# Gradio ์ธํฐํ์ด์ค ์ค์
|
108 |
def create_dashboard():
|
109 |
with gr.Blocks(css=css) as app:
|
|
|
116 |
refresh_button = gr.Button("์ํ ์๋ก๊ณ ์นจ")
|
117 |
refresh_button.click(fn=update_status, outputs=status_html)
|
118 |
|
|
|
|
|
|
|
119 |
# ์ด๊ธฐ ์ํ ์
๋ฐ์ดํธ
|
120 |
app.load(fn=update_status, outputs=status_html)
|
121 |
+
|
122 |
+
# ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์ฃผ๊ธฐ์ ์
๋ฐ์ดํธ ์์
|
123 |
+
threading.Thread(target=periodic_update, args=(status_html,), daemon=True).start()
|
124 |
|
125 |
return app
|
126 |
|