bnews3 / app.py
seawolf2357's picture
Update app.py
01b6321 verified
raw
history blame
5.85 kB
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()