Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,32 +9,32 @@ WEBSITES = {
|
|
9 |
def open_website(website_name):
|
10 |
"""
|
11 |
Function to retrieve the website URL from the dictionary.
|
12 |
-
|
13 |
"""
|
14 |
url = WEBSITES.get(website_name)
|
15 |
if url:
|
16 |
-
|
|
|
17 |
else:
|
18 |
-
return "Website not found
|
19 |
|
20 |
# Define the Gradio interface
|
21 |
with gr.Blocks() as demo:
|
22 |
gr.Markdown("# Website Selector Tool")
|
23 |
gr.Markdown("""
|
24 |
-
This tool allows you to select a website
|
25 |
-
Click the 'Open Website' button to get the link!
|
26 |
""")
|
27 |
|
28 |
-
# Dropdown for selecting website
|
29 |
website_name = gr.Dropdown(list(WEBSITES.keys()), label="Select a Website")
|
30 |
|
31 |
-
# Button to trigger website
|
32 |
open_btn = gr.Button("Open Website")
|
33 |
|
34 |
-
#
|
35 |
-
result = gr.
|
36 |
|
37 |
-
# Click event
|
38 |
open_btn.click(open_website, inputs=website_name, outputs=result)
|
39 |
|
40 |
demo.launch()
|
|
|
9 |
def open_website(website_name):
|
10 |
"""
|
11 |
Function to retrieve the website URL from the dictionary.
|
12 |
+
It embeds the selected website URL in an HTML iframe for interactive viewing.
|
13 |
"""
|
14 |
url = WEBSITES.get(website_name)
|
15 |
if url:
|
16 |
+
# Embed the website URL inside an iframe for interactive viewing
|
17 |
+
return f'<iframe src="{url}" width="100%" height="600"></iframe>'
|
18 |
else:
|
19 |
+
return "<p>Website not found.</p>"
|
20 |
|
21 |
# Define the Gradio interface
|
22 |
with gr.Blocks() as demo:
|
23 |
gr.Markdown("# Website Selector Tool")
|
24 |
gr.Markdown("""
|
25 |
+
This tool allows you to select and interact with a website in an embedded viewer.
|
|
|
26 |
""")
|
27 |
|
28 |
+
# Dropdown for selecting a website
|
29 |
website_name = gr.Dropdown(list(WEBSITES.keys()), label="Select a Website")
|
30 |
|
31 |
+
# Button to trigger website embedding
|
32 |
open_btn = gr.Button("Open Website")
|
33 |
|
34 |
+
# HTML component to display the selected website in an iframe
|
35 |
+
result = gr.HTML(label="Interactive Website Viewer")
|
36 |
|
37 |
+
# Click event to retrieve the website and embed it in the iframe
|
38 |
open_btn.click(open_website, inputs=website_name, outputs=result)
|
39 |
|
40 |
demo.launch()
|