Spaces:
Running
Running
import gradio as gr | |
import requests | |
import logging | |
import threading | |
import time | |
# ๋ก๊น ์ค์ | |
logging.basicConfig(level=logging.INFO) | |
css = """ | |
footer { visibility: hidden; } | |
.status-button { | |
display: inline-block; | |
padding: 5px 10px; | |
margin: 5px; | |
border-radius: 5px; | |
font-size: 12px; | |
} | |
.status-normal { background-color: green; color: white; } | |
.status-abnormal { background-color: red; color: white; } | |
""" | |
# ๋ชจ๋ํฐ๋ง ๋์ ๋ชฉ๋ก | |
TARGETS = [ | |
{"name": "[GINI/DS]ํ ์คํธ", "url": "http://hugpu.ai:8888"}, | |
{"name": "[OFAI/DS]ํ ์คํธ", "url": "http://hugpu.ai:8888"}, | |
{"name": "[HF]ํ ์คํธ", "url": "http://hugpu.ai:8888"}, | |
{"name": "[H100]AI ๊ฐ์ธ๋น์ JinJAVIS", "url": "http://hugpu.ai:8000"}, | |
{"name": "[HUGPU]FLUX ํ์ฅ ์ด๋ฏธ์ง ์์ฑ", "url": "https://fantaxy-ofai-flx-expl-store.hf.space"}, | |
{"name": "[HUGPU]FLUX GIF ์์ฑ", "url": "https://aiqtech-flxgif.hf.space"}, | |
{"name": "[HUGPU]LOGO ๋์์ธ ์์ฑ ", "url": "https://fantaxy-ofai-flx-logo.hf.space"}, | |
{"name": "[HUGPU]FLUX ํ๋กฌํํธ ์์ฑ ", "url": "https://ginipick-flux-prompt-generator.hf.space"}, | |
{"name": "[HUGPU]ํ๋กฌํํธ+์ด๋ฏธ์ง๋ก ์ด๋ฏธ์ง ์์ฑ ", "url": "https://.hf.space"}, ##์๋ชป๋ URL: INDEX.HTML๋ ์์ ํ ๊ฒ | |
{"name": "[HUGPU]LoRA: ๊ธฐ๋ธ๋ฆฌ ์คํ์ผ ", "url": "https://aiqtech-flux-ghibli-studio-lora.hf.space"}, | |
{"name": "[HUGPU]LoRA: ์นดํฐ ์คํ์ผ ", "url": "https://aiqtech-flxani.hf.space"}, | |
{"name": "[HUGPU]FLUX 8step LoRA ์ด๋ฏธ์ง ์์ฑ ", "url": "https://fantos-flx8lora.hf.space"}, | |
{"name": "[HUGPU]FLUX ํ ์คํธ TO ๋น๋์ค ์์ฑ ", "url": "https://fantos-cogvidx.hf.space"}, | |
{"name": "[HUGPU]FLUX ํจ์ ๋ชจ๋ธ ์์ฑ ", "url": "https://fantos-flxfashmodel.hf.space"}, | |
{"name": "[HUGPU]FLUX Controlnet ", "url": "https://fantos-flxcontrol.hf.space"}, | |
{"name": "[HUGPU]FLUX NF4 ์ด๋ฏธ์ง ์์ฑ ", "url": "https://ginipick-ofai-flxnf4.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
{"name": "[HUGPU] ", "url": "https://.hf.space"}, | |
] | |
# URL ์ํ ํ์ธ ํจ์ | |
def check_url_status(url): | |
try: | |
response = requests.get(url, timeout=5) | |
if response.status_code == 200: | |
logging.info(f"URL ์ ์ ์ฑ๊ณต: {url}") | |
return "์ ์", "normal" | |
else: | |
logging.error(f"URL ์ ์ ์ค๋ฅ: {url}, ์ํ ์ฝ๋ {response.status_code}") | |
return "๋น์ ์", "abnormal" | |
except requests.exceptions.RequestException as e: | |
logging.exception(f"์๋ฒ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค: {url}") | |
return "๋น์ ์", "abnormal" | |
# ์ํ ์ ๋ฐ์ดํธ ํจ์ | |
def update_status(): | |
status_html = "" | |
for target in TARGETS: | |
status, status_class = check_url_status(target["url"]) | |
status_html += f'<span class="status-button status-{status_class}">{target["name"]}: {status}</span>' | |
return status_html | |
# ์ฃผ๊ธฐ์ ์ ๋ฐ์ดํธ๋ฅผ ์ํ ํจ์ | |
def periodic_update(status_html): | |
while True: | |
time.sleep(10) # 10์ด ๋๊ธฐ | |
new_status = update_status() | |
status_html.update(value=new_status) | |
# Gradio ์ธํฐํ์ด์ค ์ค์ | |
def create_dashboard(): | |
with gr.Blocks(css=css) as app: | |
gr.Image("banner.png", show_label=False) | |
gr.Markdown("# 24์๊ฐ ๋ชจ๋ํฐ๋ง ์์คํ ") | |
gr.Markdown("## \n") | |
status_html = gr.HTML() | |
refresh_button = gr.Button("์ํ ์๋ก๊ณ ์นจ") | |
refresh_button.click(fn=update_status, outputs=status_html) | |
# ์ด๊ธฐ ์ํ ์ ๋ฐ์ดํธ | |
app.load(fn=update_status, outputs=status_html) | |
# ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์ฃผ๊ธฐ์ ์ ๋ฐ์ดํธ ์์ | |
threading.Thread(target=periodic_update, args=(status_html,), daemon=True).start() | |
return app | |
if __name__ == "__main__": | |
dashboard = create_dashboard() | |
dashboard.launch() |