File size: 1,491 Bytes
d870b92
 
 
 
 
 
b262257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d870b92
 
814d7c2
d870b92
f34e2bf
b262257
 
 
 
 
 
 
 
 
 
 
cc43c63
b262257
 
 
 
d870b92
 
b262257
 
 
 
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
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()