bnews3 / app.py
seawolf2357's picture
Update app.py
b262257 verified
raw
history blame
1.49 kB
css = """
footer {
visibility: hidden;
}
"""
import gradio as gr
import requests
import time
# URL μƒνƒœλ₯Ό μ²΄ν¬ν•˜λŠ” ν•¨μˆ˜
def check_url_status():
try:
response = requests.get("http://hugpu.ai:8000")
if response.status_code == 200:
return "정상", "green" # 정상적인 경우 녹색 ν‘œμ‹œ
else:
return "이상", "red" # 이상이 μžˆλŠ” 경우 뢉은색 ν‘œμ‹œ
except requests.exceptions.RequestException:
return "이상", "red" # μ—°κ²° μ‹€νŒ¨ μ‹œ 뢉은색 ν‘œμ‹œ
# Gradio μΈν„°νŽ˜μ΄μŠ€ ꡬ성
def create_dashboard():
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as app:
gr.Image("banner.png", show_label=False)
gr.Markdown("# μ „λ¬Έ μ‹œμŠ€ν…œ κ·Έλ£Ή")
gr.Markdown("## \n")
status_label, status_box = gr.Row([
gr.Textbox(label="AI κ°œμΈλΉ„μ„œ μƒνƒœ:", value="", interactive=False),
gr.Label(value="", elem_id="status_box")
])
def update_status():
status, color = check_url_status()
status_label.update(value=f"AI κ°œμΈλΉ„μ„œ μƒνƒœ: {status}")
status_box.update(style={'backgroundColor': color})
gr.update()
# 주기적으둜 μƒνƒœ μ—…λ°μ΄νŠΈ
gr.update(value=update_status, repeat=60) # 1뢄에 ν•œ λ²ˆμ”© μ—…λ°μ΄νŠΈ
return app
if __name__ == "__main__":
dashboard = create_dashboard()
dashboard.launch()