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()