File size: 4,639 Bytes
d05f4a2
 
 
 
 
e928cee
 
50e7ded
e928cee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50e7ded
e928cee
 
 
 
 
 
50e7ded
e928cee
 
 
50e7ded
e928cee
 
 
 
 
 
 
 
 
 
d05f4a2
eb495ea
 
76adcc4
ebbe279
76adcc4
 
 
 
 
 
6554c70
88a8acf
9cd1db8
df0ca78
 
 
 
 
 
46c513b
 
fec19bd
b33ed4e
c9f7633
4082c45
092eeba
576ca2b
0674963
8eb4fcf
a4d88d2
 
 
 
3455948
 
c121eb4
b1b4b83
a2aa1df
9e4dfdb
79b8971
8c38a31
6554c70
e928cee
 
 
 
50e7ded
e928cee
 
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import gradio as gr
import aiohttp
import asyncio
import threading

# ๋น„๋™๊ธฐ์ ์œผ๋กœ ์™ธ๋ถ€ URL์— ์ ‘์†ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
async def check_connection(url):
    try:
        async with aiohttp.ClientSession() as session:
            async with session.get(url) as response:
                status = f"URL: {url} ์ƒํƒœ ์ฝ”๋“œ: {response.status}, ์ ‘์† ์ƒํƒœ: {'์ ‘์† ์„ฑ๊ณต' if response.status == 200 else '์ ‘์† ์‹คํŒจ'}"
                print(status)
                return status
    except Exception as e:
        status = f"URL: {url} ์ ‘์† ์‹คํŒจ: {str(e)}"
        print(status)
        return status

# ํƒ€์ด๋จธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ •ํ•ด์ง„ ์ฃผ๊ธฐ๋กœ ๋น„๋™๊ธฐ ํ•จ์ˆ˜๋ฅผ ๋ฐ˜๋ณต ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
async def start_timer(urls, interval):
    while True:
        for url in urls:
            if url:  # URL์ด ๋น„์–ด ์žˆ์ง€ ์•Š์œผ๋ฉด ์ฒดํฌ
                await check_connection(url)
                await asyncio.sleep(1)  # ๊ฐ URL ์ฒดํฌ ํ›„ 1์ดˆ ๋Œ€๊ธฐ
        await asyncio.sleep(interval - len(urls))  # ๋ชจ๋“  URL ์ฒดํฌ ํ›„ interval์—์„œ ์ด๋ฏธ ์†Œ๋น„๋œ ์‹œ๊ฐ„์„ ๋บ€ ๋งŒํผ ๋Œ€๊ธฐ

# ํƒ€์ด๋จธ ์‹œ์ž‘ ํ•จ์ˆ˜๋ฅผ Gradio์˜ ์ž…๋ ฅ๊ณผ ํ•จ๊ป˜ ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค.
def setup_timer(interval, *urls):
    interval_seconds = interval * 60  # ๋ถ„์„ ์ดˆ๋กœ ๋ณ€ํ™˜
    # ๋น„๋™๊ธฐ ์ž‘์—…์„ ๋ณ„๋„์˜ ์Šค๋ ˆ๋“œ์—์„œ ์‹คํ–‰
    threading.Thread(target=asyncio.run, args=(start_timer(urls, interval_seconds),)).start()
    return "ํƒ€์ด๋จธ๊ฐ€ ์„ค์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค."

# Gradio UI ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.
url_inputs = [gr.Text(label=f"URL {i+1}", placeholder=f"์ ‘์†ํ•  URL {i+1}์„ ์ž…๋ ฅํ•˜์„ธ์š”") for i in range(40)]
interval_input = gr.Slider(minimum=1, maximum=60, step=1, value=5, label="์ ‘์† ์ฃผ๊ธฐ(๋ถ„)")

# Gradio ์•ฑ ์„ค์ •
app = gr.Interface(
    fn=setup_timer,
    inputs=[interval_input] + url_inputs,
    outputs="text",
    title="URL ์ ‘์† ์ฒด์ปค",
    description="์ตœ๋Œ€ 40๊ฐœ์˜ URL๊ณผ ์ ‘์† ์ฃผ๊ธฐ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  '์‹œ์ž‘' ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์„ธ์š”. ์ง€์ •๋œ ์ฃผ๊ธฐ๋กœ HTTP ์ƒํƒœ ์ฝ”๋“œ ๋ฐ ์ ‘์† ์ƒํƒœ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.",
    examples=[
        [
            15,
            "https://fantaxy-timer1.hf.space",  
#            "https://seawolf2357-FastGPT.hf.space",
#            "https://seawolf2357-NaverTalk.hf.space",
            "https://fantaxy-kai-llm-claude35.hf.space",
            "https://fantaxy-kai-llm-gpt4o.hf.space",
            "https://fantaxy-kai-llm-l370b.hf.space",
            "https://fantaxy-kai-llm-l38b.hf.space",
            "https://fantaxy-kai-llm-phi3.hf.space",
            "https://fantaxy-kai-llm-mix87.hf.space",
            "https://fantaxy-kai-llm-aya.hf.space",
            "https://fantaxy-kai-llm-zepr.hf.space",
            "https://fantaxy-kai-llm-yi.hf.space",
            "https://ginipick-kai-llm-law1.hf.space",
 #           "https://fantaxy-kai-allsend.hf.space",
            "https://fantaxy-kai-charac-yok.hf.space",
            "https://fantaxy-kai-charac-mbti.hf.space",
            "https://fantaxy-kai-charac-girlfriend.hf.space",
            "https://fantaxy-kai-charac-ana.hf.space",
            "https://fantaxy-kai-charac-pluting.hf.space",
            "https://fantaxy-kai-charac-simsim.hf.space",
            "https://fantaxy-kai-charac-boyfriend.hf.space",   
            "https://fantaxy-kai-llm-persona.hf.space",
            "https://fantaxy-kai-llm-trans.hf.space",
            "https://fantaxy-kai-llm-code.hf.space",
            "https://fantaxy-kai-llm-novel.hf.space",
            "https://ginipick-gini-ytb-private-replysend.hf.space",
            "https://seawolf2357-kai-saju.hf.space",
            "https://ginipick-gini-saju.hf.space",
            "https://fantos-opencodeai.hf.space",
            "https://seawolf2357-kai-l3-405b.hf.space",
            "https://ginipick-gini-api-chat.hf.space",
            "https://ginipick-gini-api-blog.hf.space",
            "https://ginipick-gini-api-script.hf.space",
            "https://ginipick-gini-api-market.hf.space",
            "https://seawolf2357-kai-llm-mislarge2.hf.space",
            "https://seawolf2357-kai-llm-upstage.hf.space",
            "https://seawolf2357-kai-llm-medi.hf.space",
            "https://seawolf2357-kai-llm-pharm.hf.space",
            "https://seawolf2357-kai-llm-insu.hf.space",
            "https://seawolf2357-kai-llm-search.hf.space",
            "https://seawolf2357-kai-llm-copy.hf.space",
            "https://ginipick-EXAONE-3.0-7.8B-Instruct.hf.space",
            "https://fantaxy-kai-llm-math.hf.space"
        ]
    ],
    cache_examples=False  # ์บ์‹œ ๋น„ํ™œ์„ฑํ™”
)

if __name__ == "__main__":
    app.launch()