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-timer.hf.space", "https://ginipick-discord-openfree-LLM-chatgpt4.hf.space", "https://fantos-discord-openfree-LLM-qwen3-30b-a3b.hf.space", "https://fantos-discord-openfree-LLM-qwen3-235b-a22b.hf.space", "https://fantos-discord-openfree-LLM-llama4-maverick-instruct.hf.space", "https://fantos-discord-openfree-LLM-llama4-scout-instruct.hf.space", "https://fantos-discord-openfree-LLM-deepseek-v3-0324.hf.space", "https://fantos-discord-openfree-Image-sdxl-lightning.hf.space", "https://fantos-discord-openfree-Image-flux.hf.space", "https://fantos-discord-openfree-Image-3d.hf.space", "https://fantos-discord-openfree-video-luma.hf.space", "https://fantos-discord-openfree-video-luma2.hf.space" ] ], cache_examples=False # 캐시 비활성화 ) app.launch()