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()