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-FastGPT.hf.space", | |
"https://seawolf2357-NaverTalk.hf.space", | |
"https://seawolf2357-timer.hf.space", | |
"https://seawolf2357-timer3.hf.space", | |
"https://seawolf2357-kai-chatbot.hf.space", | |
"https://seawolf2357-gini-girlfriend.hf.space", | |
"https://seawolf2357-gini-boyfriend.hf.space", | |
"https://seawolf2357-kai-grandma.hf.space", | |
"https://seawolf2357-kai-simsime.hf.space", | |
"https://seawolf2357-kai-blog.hf.space", | |
"https://seawolf2357-kai-anak.hf.space", | |
"https://seawolf2357-kai-trans.hf.space", | |
"https://seawolf2357-kai-sum.hf.space", | |
"https://seawolf2357-kai-l3-70b.hf.space", | |
"https://seawolf2357-kai-l3-8b.hf.space", | |
"https://seawolf2357-kai-aya23-35B.hf.space", | |
"https://seawolf2357-kai-law.hf.space", | |
"https://seawolf2357-kai-law2.hf.space", | |
"https://seawolf2357-kai-zephyr.hf.space", | |
"https://seawolf2357-kai-mistral.hf.space", | |
"https://seawolf2357-kai-commu-dc.hf.space", | |
"https://seawolf2357-kai-commu-1253181097311731712.hf.space", | |
"https://seawolf2357-kai-commu-1253181128152449075.hf.space", | |
"https://ginipick-kai-commu-1253181193180942367.hf.space", | |
"https://ginipick-kai-commu-1253181193180942367.hf.space", | |
"https://ginipick-kai-commu-1253181238676557884.hf.space", | |
"https://ginipick-kai-commu-1253181258561884161.hf.space", | |
"https://ginipick-kai-commu-1253181305739411567.hf.space", | |
"https://ginipick-kai-commu-1253181326060949585.hf.space", | |
"https://ginipick-kai-commu-1253181359371980892.hf.space", | |
"https://ginipick-kai-commu-1253181380091973715.hf.space", | |
"https://ginipick-kai-commu-1253181427605045329.hf.space", | |
"https://ginipick-kai-commu-1253181449008320553.hf.space", | |
"https://ginipick-kai-commu-1253181487818211348.hf.space", | |
"https://ginipick-kai-commu-1253181517593837568.hf.space", | |
"https://ginipick-kai-commu-1253181557233946665.hf.space", | |
"https://ginipick-kai-commu-1253181575252803634.hf.space", | |
"https://ginipick-kai-commu-1253181626750341141.hf.space", | |
"https://ginipick-avatar.hf.space", #์๋ฐํ ์คํ๋์ค ํ์ผ๋ค ์ ๋ก๋ ๋ฑ๋ก ํ๋ ์๋น์ค(์ ์ ์ง์๋ค ๊ด๋ฆฌ์ฉ) | |
"https://fantaxy-kai-tts.hf.space" | |
] | |
], | |
cache_examples=False # ์บ์ ๋นํ์ฑํ | |
) | |
app.launch() | |