AINovice2005 commited on
Commit
4029298
·
verified ·
1 Parent(s): 09daeb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
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
- Handles cases where the website name doesn't exist.
13
  """
14
  url = WEBSITES.get(website_name)
15
  if url:
16
- return url
 
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 and view its URL.
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 retrieval
32
  open_btn = gr.Button("Open Website")
33
 
34
- # Textbox to display the URL of the selected website
35
- result = gr.Textbox(label="Website URL", interactive=False)
36
 
37
- # Click event that retrieves the website URL and displays it
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()