Spaces:
Running
Running
import gradio as gr | |
import requests | |
import threading | |
import time | |
# ์ธ๋ถ URL์ ์ ์ํ๋ ํจ์๋ฅผ ์ ์ํฉ๋๋ค. | |
def check_connection(url): | |
try: | |
response = requests.get(url) | |
status = f"URL: {url} ์ํ ์ฝ๋: {response.status_code}, ์ ์ ์ํ: {'์ ์ ์ฑ๊ณต' if response.status_code == 200 else '์ ์ ์คํจ'}" | |
except Exception as e: | |
status = f"URL: {url} ์ ์ ์คํจ: {str(e)}" | |
print(status) | |
return status | |
# ํ์ด๋จธ๋ฅผ ์ฌ์ฉํ์ฌ ์ ํด์ง ์ฃผ๊ธฐ๋ก ํจ์๋ฅผ ๋ฐ๋ณต ์คํํฉ๋๋ค. | |
def start_timer(url, interval): | |
threading.Timer(interval, start_timer, [url, interval]).start() | |
check_connection(url) | |
# ํ์ด๋จธ ์์ ํจ์๋ฅผ Gradio์ ์ ๋ ฅ๊ณผ ํจ๊ป ์ฐ๊ฒฐํฉ๋๋ค. | |
def setup_timer(interval, *urls): | |
interval_seconds = interval * 60 # ๋ถ์ ์ด๋ก ๋ณํ | |
for url in urls: | |
if url: # URL์ด ๋น์ด ์์ง ์์ผ๋ฉด ํ์ด๋จธ ์์ | |
start_timer(url, interval_seconds) | |
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://seawolf2357-l3-405b.hf.space", | |
"https://seawolf2357-NaverTalk.hf.space", | |
"https://seawolf2357-timer2.hf.space", | |
"https://seawolf2357-kai-code.hf.space", | |
"https://fantaxy-kai-chat-speech.hf.space", | |
"https://fantaxy-kai-ytb-audio.hf.space", | |
"https://seawolf2357-kai-allsend.hf.space", | |
"https://seawolf2357-kai-phi3.hf.space", | |
"https://seawolf2357-kai-yi.hf.space", | |
"https://seawolf2357-kai-allsend.hf.space", | |
"https://seawolf2357-kai-imgsearch.hf.space", | |
"https://seawolf2357-kai-vidsearch.hf.space", | |
"https://seawolf2357-kai-ytb-private-reply.hf.space", | |
"https://seawolf2357-kai-ytb-private-replysend.hf.space", | |
"https://fantaxy-kai-ytb-blog.hf.space", | |
"https://seawolf2357-kai-paper.hf.space", | |
"https://fantaxy-kai-person-hWang.hf.space", | |
"https://fantaxy-kai-person-musk.hf.space", | |
"https://fantaxy-kai-person-jobs.hf.space", | |
"https://fantaxy-kai-person-eins.hf.space", | |
"https://fantaxy-kai-person-lee.hf.space", | |
"https://fantaxy-kai-girlfriend19.hf.space", | |
"https://seawolf2357-kai-ytb-private-replysend-custom.hf.space", | |
"https://seawolf2357-kai-mbti.hf.space", | |
"https://seawolf2357-kai-salary.hf.space", | |
"https://seawolf2357-kai-llm-claude35.hf.space", | |
"https://seawolf2357-kai-llm-gpt4o.hf.space", | |
"https://seawolf2357-kai-novel.hf.space", | |
"https://seawolf2357-kai-bodo.hf.space", | |
"https://fantaxy-youtubedown.hf.space", | |
"https://seawolf2357-pandaitest.hf.space", | |
"https://seawolf2357-kai-math.hf.space", | |
"https://ginipick-gini-llm-chatbot-text.hf.space", #ginipick llm | |
"https://ginipick-gini-llm-chat-speech.hf.space", | |
"https://ginipick-gini-llm-blog.hf.space", | |
"https://seawolf2357-kai-ytb-private-replysend-real.hf.space", | |
"https://seawolf2357-kai-ytb-search1.hf.space", | |
"https://seawolf2357-kai-vision.hf.space", | |
"https://seawolf2357-kai-autonews.hf.space", | |
"https://seawolf2357-kai-ytb-music.hf.space" | |
] | |
], | |
cache_examples=False # ์บ์ ๋นํ์ฑํ | |
) | |
app.launch() | |