Commit
·
09ceaa9
1
Parent(s):
c1ca8a4
adjust output types
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
from typing import Tuple
|
|
|
2 |
import gradio as gr
|
3 |
import requests
|
4 |
|
@@ -9,7 +10,10 @@ def is_active(url) -> Tuple[bool, str]:
|
|
9 |
if 200 <= response.status_code < 300:
|
10 |
return True, f"The website {url} is active."
|
11 |
else:
|
12 |
-
return
|
|
|
|
|
|
|
13 |
except requests.ConnectionError:
|
14 |
return False, f"Failed to connect to {url}."
|
15 |
except requests.Timeout:
|
@@ -21,7 +25,10 @@ def is_active(url) -> Tuple[bool, str]:
|
|
21 |
demo = gr.Interface(
|
22 |
fn=is_active,
|
23 |
inputs="text",
|
24 |
-
outputs=
|
|
|
|
|
|
|
25 |
title="Website Activity Checker",
|
26 |
description="Enter a URL to check if the website is active.",
|
27 |
allow_flagging="never",
|
|
|
1 |
from typing import Tuple
|
2 |
+
|
3 |
import gradio as gr
|
4 |
import requests
|
5 |
|
|
|
10 |
if 200 <= response.status_code < 300:
|
11 |
return True, f"The website {url} is active."
|
12 |
else:
|
13 |
+
return (
|
14 |
+
False,
|
15 |
+
f"The website {url} returned status code {response.status_code}.",
|
16 |
+
)
|
17 |
except requests.ConnectionError:
|
18 |
return False, f"Failed to connect to {url}."
|
19 |
except requests.Timeout:
|
|
|
25 |
demo = gr.Interface(
|
26 |
fn=is_active,
|
27 |
inputs="text",
|
28 |
+
outputs=[
|
29 |
+
gr.Textbox(label="Status (True/False)"),
|
30 |
+
gr.Textbox(label="Message"),
|
31 |
+
],
|
32 |
title="Website Activity Checker",
|
33 |
description="Enter a URL to check if the website is active.",
|
34 |
allow_flagging="never",
|