Spaces:
Running
Running
File size: 1,247 Bytes
dd7fe10 0e61863 dd7fe10 0e61863 dd7fe10 0e61863 e26a87b c5d7fd8 0e61863 dd7fe10 0e61863 dd7fe10 0e61863 c5d7fd8 0e61863 c5d7fd8 0e61863 |
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 30 31 32 33 34 35 |
import gradio as gr
import requests
# μΈλΆ URLμ μ μνλ ν¨μλ₯Ό μ μν©λλ€.
def check_connection(url):
try:
# URLμ GET μμ²μ 보λ
λλ€.
response = requests.get(url)
# HTTP μν μ½λμ μ μ μνλ₯Ό λ°νν©λλ€.
status = f"μν μ½λ: {response.status_code}, μ μ μν: {'μ μ μ±κ³΅' if response.status_code == 200 else 'μ μ μ€ν¨'}"
return status
except Exception as e:
# μμ²μ΄ μ€ν¨ν κ²½μ°, μ€ν¨ μ΄μ λ₯Ό λ°νν©λλ€.
return f"μ μ μ€ν¨: {str(e)}"
# Gradio UI μ»΄ν¬λνΈλ₯Ό μ μν©λλ€.
url_input = gr.Text(label="URL", placeholder="μ μν URLμ μ
λ ₯νμΈμ")
output_text = gr.Textbox(label="μ μ μν")
# Gradio μ ν리μΌμ΄μ
μ μ€μ νκ³ μ€νν©λλ€.
title = "URL μ μ 체컀"
description = "URLμ μ
λ ₯νκ³ 'μ μ 체ν¬'λ₯Ό ν΄λ¦νμ¬ HTTP μν μ½λ λ° μ μ μνλ₯Ό νμΈνμΈμ."
examples = [["https://www.example.com"]]
# Gradio μ±μ μμ±νκ³ μ€νν©λλ€.
app = gr.Interface(
fn=check_connection,
inputs=url_input,
outputs=output_text,
title=title,
description=description,
examples=examples
)
app.launch(share=True)
|