Spaces:
Running
Running
File size: 2,630 Bytes
dd7fe10 45a4d1c dd7fe10 0e61863 dd7fe10 1eb1070 c5d7fd8 1eb1070 45a4d1c dd7fe10 0e61863 1eb1070 89803fa f8eb695 53703b0 dd7fe10 45a4d1c f8eb695 45a4d1c 1eb1070 89803fa f8eb695 45a4d1c c5d7fd8 45a4d1c 0e61863 45a4d1c f8eb695 45a4d1c f8eb695 1eb1070 18cc60d 1e4a472 0e61863 f8eb695 |
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 |
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 UI ์ปดํฌ๋ํธ๋ฅผ ์ ์ํฉ๋๋ค.
url_input1 = gr.Text(label="URL 1", placeholder="์ ์ํ ์ฒซ ๋ฒ์งธ URL์ ์
๋ ฅํ์ธ์")
url_input2 = gr.Text(label="URL 2", placeholder="์ ์ํ ๋ ๋ฒ์งธ URL์ ์
๋ ฅํ์ธ์")
url_input3 = gr.Text(label="URL 3", placeholder="์ ์ํ ์ธ ๋ฒ์งธ URL์ ์
๋ ฅํ์ธ์")
url_input4 = gr.Text(label="URL 4", placeholder="์ ์ํ ๋ค ๋ฒ์งธ URL์ ์
๋ ฅํ์ธ์")
url_input5 = gr.Text(label="URL 5", placeholder="์ ์ํ ๋ค์ฏ ๋ฒ์งธ URL์ ์
๋ ฅํ์ธ์")
url_input6 = gr.Text(label="URL 6", placeholder="์ ์ํ ์ฌ์ฏ ๋ฒ์งธ URL์ ์
๋ ฅํ์ธ์")
interval_input = gr.Slider(minimum=1, maximum=60, step=1, value=5, label="์ ์ ์ฃผ๊ธฐ(๋ถ)")
# ํ์ด๋จธ ์์ ํจ์๋ฅผ Gradio์ ์
๋ ฅ๊ณผ ํจ๊ป ์ฐ๊ฒฐํฉ๋๋ค.
def setup_timer(url1, url2, url3, url4, url5, url6, interval):
interval_seconds = interval * 60 # ๋ถ์ ์ด๋ก ๋ณํ
start_timer(url1, interval_seconds)
start_timer(url2, interval_seconds)
start_timer(url3, interval_seconds)
start_timer(url4, interval_seconds)
start_timer(url5, interval_seconds)
start_timer(url6, interval_seconds)
return "ํ์ด๋จธ๊ฐ ์ค์ ๋์์ต๋๋ค."
# Gradio ์ฑ ์ค์
app = gr.Interface(
fn=setup_timer,
inputs=[url_input1, url_input2, url_input3, url_input4, url_input5, url_input6, interval_input],
outputs="text",
title="URL ์ ์ ์ฒด์ปค",
description="์ฌ์ฏ ๊ฐ์ URL๊ณผ ์ ์ ์ฃผ๊ธฐ๋ฅผ ์
๋ ฅํ๊ณ '์์' ๋ฒํผ์ ํด๋ฆญํ์ธ์. ์ง์ ๋ ์ฃผ๊ธฐ๋ก HTTP ์ํ ์ฝ๋ ๋ฐ ์ ์ ์ํ๋ฅผ ํ์ธํฉ๋๋ค.",
examples=[
["https://seawolf2357-FastGPT.hf.space", "https://seawolf2357-NaverTalk.hf.space", "https://seawolf2357-timer.hf.space", "https://seawolf2357-timer2.hf.space", "https://seawolf2357-disc1ch-2.hf.space", "https:/https:/seawolf2357-kai-girlfriend.hf.space/", 15]
],
cache_examples=False # ์บ์ ๋นํ์ฑํ
)
app.launch()
|