seawolf2357 commited on
Commit
dd7fe10
ยท
verified ยท
1 Parent(s): d2acde4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # ์™ธ๋ถ€ URL์— ์ ‘์†ํ•˜๋Š” ํ•จ์ˆ˜ ์ •์˜
5
+ def check_connection(url):
6
+ try:
7
+ # URL์— GET ์š”์ฒญ์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.
8
+ response = requests.get(url)
9
+ # HTTP ์ƒํƒœ ์ฝ”๋“œ์™€ ํ•จ๊ป˜ ์ ‘์† ์ƒํƒœ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
10
+ return f"Status Code: {response.status_code}, Connection Status: {'Connection successful' if response.status_code == 200 else 'Connection failed'}"
11
+ except:
12
+ # ์š”์ฒญ์ด ์‹คํŒจํ–ˆ์„ ๊ฒฝ์šฐ
13
+ return "Connection failed"
14
+
15
+ # ๊ทธ๋ผ๋””์˜ค UI ์ •์˜
16
+ url_input = gr.inputs.Textbox(label="URL", placeholder="Enter the URL to check")
17
+ output_text = gr.outputs.Textbox(label="Connection Status")
18
+
19
+ # ๊ทธ๋ผ๋””์˜ค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰
20
+ title = "URL Connection Checker"
21
+ description = "Enter a URL and click 'Check Connection' to see the HTTP status code and connection status."
22
+ examples = [["https://seawolf2357-fastgpt.hf.space/"]]
23
+ timer_input = gr.inputs.Slider(minimum=1, maximum=60, default=5, label="Check Interval (minutes)")
24
+ gr.Interface(check_connection, inputs=url_input, outputs=output_text, title=title, description=description, examples=examples, server_name="0.0.0.0", server_port=7860).launch(inline=False, inbrowser=True, share=True)