timer3 / app.py
seawolf2357's picture
Update app.py
f77ea48 verified
raw
history blame
4.12 kB
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=15, 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-kai-flx.hf.space",
"https://seawolf2357-timer.hf.space",
"https://seawolf2357-timer2.hf.space",
"https://fantaxy-timer1.hf.space",
"https://fantaxy-timer2.hf.space",
"https://seawolf2357-kai-pluting.hf.space",
"https://fantaxy-kai-flx-id.hf.space",
"https://seawolf2357-ofai-405.hf.space",#์—ฌ๊ธฐ๋ถ€ํ„ฐ openfree.ai ์„œ๋น„์Šค์šฉ ๋ฐฐ์น˜ ์‹œ์ž‘
"https://fantaxy-ofai-70.hf.space",
"https://seawolf2357-ofai-8.hf.space",
"https://seawolf2357-ofai-Mistral-Nemo.hf.space",
"https://fantaxy-ofai-8x7b.hf.space",
"https://fantaxy-ofai-phi.hf.space",
"https://fantaxy-ofai-Yi.hf.space",
"https://fantaxy-ofai-mis7b.hf.space",
"https://fantaxy-ofai-kai.hf.space",
# "https://fantaxy-ofai-flx-expl-notio.hf.space",
"https://fantaxy-ofai-it2v2.hf.space",
"https://fantaxy-ofai-flx-expl-store.hf.space",
"https://fantaxy-ofai-t2v.hf.space",
"https://ginipick-FLUX-Prompt-Generator.hf.space",
"https://seawolf2357-fake-insects.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()