File size: 1,332 Bytes
dd7fe10
 
 
 
 
 
 
 
 
e26a87b
 
 
 
dd7fe10
 
e26a87b
dd7fe10
 
 
82b5fd4
 
dd7fe10
 
 
 
 
b281c94
f49559c
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
import gradio as gr
import requests

# ์™ธ๋ถ€ URL์— ์ ‘์†ํ•˜๋Š” ํ•จ์ˆ˜ ์ •์˜
def check_connection(url):
    try:
        # URL์— GET ์š”์ฒญ์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.
        response = requests.get(url)
        # HTTP ์ƒํƒœ ์ฝ”๋“œ์™€ ํ•จ๊ป˜ ์ ‘์† ์ƒํƒœ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
        status = f"Status Code: {response.status_code}, Connection Status: {'Connection successful' if response.status_code == 200 else 'Connection failed'}"
        # ์—ฐ๊ฒฐ ์ƒํƒœ๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
        print(status)
        return status
    except:
        # ์š”์ฒญ์ด ์‹คํŒจํ–ˆ์„ ๊ฒฝ์šฐ
        print("Connection failed")
        return "Connection failed"

# ๊ทธ๋ผ๋””์˜ค UI ์ •์˜
url_input = gr.Interface.TextInput(label="URL", placeholder="Enter the URL to check")
output_text = gr.Interface.Textbox(label="Connection Status")

# ๊ทธ๋ผ๋””์˜ค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰
title = "URL Connection Checker"
description = "Enter a URL and click 'Check Connection' to see the HTTP status code and connection status."
examples = [["https://seawolf2357-fastgpt.hf.space/"]]
timer_input = gr.Interface.Slider(minimum=1, maximum=60, default=5, label="Check Interval (minutes)")
gr.Interface(fn=check_connection, inputs=url_input, outputs=output_text, title=title, description=description, examples=examples).launch(inline=False, inbrowser=True, share=True)