Spaces:
Sleeping
Sleeping
File size: 1,537 Bytes
dd7fe10 45a4d1c dd7fe10 0e61863 dd7fe10 0e61863 c5d7fd8 45a4d1c dd7fe10 0e61863 53703b0 dd7fe10 45a4d1c c5d7fd8 45a4d1c 0e61863 45a4d1c 53703b0 0e61863 |
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 |
import gradio as gr
import requests
import threading
import time
# ์ธ๋ถ URL์ ์ ์ํ๋ ํจ์๋ฅผ ์ ์ํฉ๋๋ค.
def check_connection(url):
try:
response = requests.get(url)
status = f"์ํ ์ฝ๋: {response.status_code}, ์ ์ ์ํ: {'์ ์ ์ฑ๊ณต' if response.status_code == 200 else '์ ์ ์คํจ'}"
except Exception as e:
status = f"์ ์ ์คํจ: {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_input = gr.Text(label="URL", placeholder="์ ์ํ URL์ ์
๋ ฅํ์ธ์")
interval_input = gr.Slider(minimum=1, maximum=60, step=1, value=5, label="์ ์ ์ฃผ๊ธฐ(๋ถ)")
# ํ์ด๋จธ ์์ ํจ์๋ฅผ Gradio์ ์
๋ ฅ๊ณผ ํจ๊ป ์ฐ๊ฒฐํฉ๋๋ค.
def setup_timer(url, interval):
interval_seconds = interval * 60 # ๋ถ์ ์ด๋ก ๋ณํ
start_timer(url, interval_seconds)
return "ํ์ด๋จธ๊ฐ ์ค์ ๋์์ต๋๋ค."
# Gradio ์ฑ ์ค์
app = gr.Interface(
fn=setup_timer,
inputs=[url_input, interval_input],
outputs="text",
title="URL ์ ์ ์ฒด์ปค",
description="URL๊ณผ ์ ์ ์ฃผ๊ธฐ๋ฅผ ์
๋ ฅํ๊ณ '์์' ๋ฒํผ์ ํด๋ฆญํ์ธ์. ์ง์ ๋ ์ฃผ๊ธฐ๋ก HTTP ์ํ ์ฝ๋ ๋ฐ ์ ์ ์ํ๋ฅผ ํ์ธํฉ๋๋ค.",
examples=[["https://seawolf2357-FastGPT.hf.space", 5]]
)
app.launch(share=True)
|