Spaces:
Running
Running
File size: 1,759 Bytes
4f2be76 4e1c32a 46a61fe 4e1c32a db7d3b2 4e1c32a 4f2be76 d870b92 2877b2d db7d3b2 d870b92 db7d3b2 b262257 db7d3b2 b262257 db7d3b2 4e1c32a db7d3b2 b262257 db7d3b2 2877b2d 46a61fe db7d3b2 46a61fe db7d3b2 b262257 4f2be76 d870b92 db7d3b2 46a61fe db7d3b2 46a61fe d870b92 db7d3b2 4f2be76 db7d3b2 2877b2d b262257 d870b92 b262257 db7d3b2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
import gradio as gr
import requests
import logging
import time
# λ‘κΉ
μ€μ
logging.basicConfig(level=logging.INFO)
css = """
footer { visibility: hidden; }
.status-normal { background-color: green; color: white; padding: 10px; border-radius: 5px; }
.status-abnormal { background-color: red; color: white; padding: 10px; border-radius: 5px; }
"""
# URL μν νμΈ ν¨μ
def check_url_status():
try:
response = requests.get("http://hugpu.ai:8000")
if response.status_code == 200:
logging.info("URL μ μ μ±κ³΅: μν μ½λ 200")
return "μ μ", "normal"
else:
logging.error(f"URL μ μ μ€λ₯: μν μ½λ {response.status_code}")
return "λΉμ μ", "abnormal"
except requests.exceptions.RequestException as e:
logging.exception("μλ²μ μ°κ²°ν μ μμ΅λλ€.")
return "λΉμ μ", "abnormal"
# μν μ
λ°μ΄νΈ ν¨μ
def update_status():
while True:
status, status_class = check_url_status()
yield f"<div class='status-{status_class}'>AI κ°μΈ λΉμ μν: {status}</div>"
time.sleep(6) # 6μ΄ λκΈ°
# Gradio μΈν°νμ΄μ€ μ€μ
def create_dashboard():
with gr.Blocks(css=css) as app:
gr.Image("banner.png", show_label=False)
gr.Markdown("# 24μκ° λͺ¨λν°λ§ μμ€ν
")
gr.Markdown("## \n")
gr.Markdown("### ν μ€λͺ
: [λ§ν¬](https://seawolf2357-bnews1.hf.space)")
gr.Markdown("## \n")
status_html = gr.HTML("AI κ°μΈ λΉμ μν: λ‘λ© μ€...")
gr.Loop(update_status, outputs=status_html, every=6)
return app
if __name__ == "__main__":
dashboard = create_dashboard()
dashboard.launch() |