Spaces:
Running
Running
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() | |