Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,9 +7,9 @@ import time
|
|
7 |
def check_connection(url):
|
8 |
try:
|
9 |
response = requests.get(url)
|
10 |
-
status = f"상태 코드: {response.status_code}, 접속 상태: {'접속 성공' if response.status_code == 200 else '접속 실패'}"
|
11 |
except Exception as e:
|
12 |
-
status = f"접속 실패: {str(e)}"
|
13 |
print(status)
|
14 |
return status
|
15 |
|
@@ -19,22 +19,26 @@ def start_timer(url, interval):
|
|
19 |
check_connection(url)
|
20 |
|
21 |
# Gradio UI 컴포넌트를 정의합니다.
|
22 |
-
|
|
|
23 |
interval_input = gr.Slider(minimum=1, maximum=60, step=1, value=5, label="접속 주기(분)")
|
24 |
|
25 |
# 타이머 시작 함수를 Gradio의 입력과 함께 연결합니다.
|
26 |
-
def setup_timer(
|
27 |
interval_seconds = interval * 60 # 분을 초로 변환
|
28 |
-
start_timer(
|
|
|
29 |
return "타이머가 설정되었습니다."
|
30 |
|
31 |
# Gradio 앱 설정
|
32 |
app = gr.Interface(
|
33 |
fn=setup_timer,
|
34 |
-
inputs=[
|
35 |
outputs="text",
|
36 |
title="URL 접속 체커",
|
37 |
-
description="URL과 접속 주기를 입력하고 '시작' 버튼을 클릭하세요. 지정된 주기로 HTTP 상태 코드 및 접속 상태를 확인합니다.",
|
38 |
-
examples=[
|
|
|
|
|
39 |
)
|
40 |
app.launch(share=True)
|
|
|
7 |
def check_connection(url):
|
8 |
try:
|
9 |
response = requests.get(url)
|
10 |
+
status = f"URL: {url} 상태 코드: {response.status_code}, 접속 상태: {'접속 성공' if response.status_code == 200 else '접속 실패'}"
|
11 |
except Exception as e:
|
12 |
+
status = f"URL: {url} 접속 실패: {str(e)}"
|
13 |
print(status)
|
14 |
return status
|
15 |
|
|
|
19 |
check_connection(url)
|
20 |
|
21 |
# Gradio UI 컴포넌트를 정의합니다.
|
22 |
+
url_input1 = gr.Text(label="URL 1", placeholder="접속할 첫 번째 URL을 입력하세요")
|
23 |
+
url_input2 = gr.Text(label="URL 2", placeholder="접속할 두 번째 URL을 입력하세요")
|
24 |
interval_input = gr.Slider(minimum=1, maximum=60, step=1, value=5, label="접속 주기(분)")
|
25 |
|
26 |
# 타이머 시작 함수를 Gradio의 입력과 함께 연결합니다.
|
27 |
+
def setup_timer(url1, url2, interval):
|
28 |
interval_seconds = interval * 60 # 분을 초로 변환
|
29 |
+
start_timer(url1, interval_seconds)
|
30 |
+
start_timer(url2, interval_seconds)
|
31 |
return "타이머가 설정되었습니다."
|
32 |
|
33 |
# Gradio 앱 설정
|
34 |
app = gr.Interface(
|
35 |
fn=setup_timer,
|
36 |
+
inputs=[url_input1, url_input2, interval_input],
|
37 |
outputs="text",
|
38 |
title="URL 접속 체커",
|
39 |
+
description="두 개의 URL과 접속 주기를 입력하고 '시작' 버튼을 클릭하세요. 지정된 주기로 HTTP 상태 코드 및 접속 상태를 확인합니다.",
|
40 |
+
examples=[
|
41 |
+
["https://seawolf2357-FastGPT.hf.space", "https://seawolf2357-NaverTalk.hf.space", 5]
|
42 |
+
]
|
43 |
)
|
44 |
app.launch(share=True)
|