IIya30_List / app.py
AINovice2005's picture
Update app.py
c0929e4 verified
import gradio as gr
# A dictionary to store website names and their URLs
WEBSITES = {
"Extended List": "https://aman.ai/primers/ai/top-30-papers/",
"Original List": "https://arc.net/folder/D0472A20-9C20-4D3F-B145-D2865C0A9FEE",
}
def open_website(website_name):
"""
Function to retrieve the website URL from the dictionary.
It embeds the selected website URL in an HTML iframe for interactive viewing.
"""
url = WEBSITES.get(website_name)
if url:
# Embed the website URL inside an iframe for interactive viewing
return f'<iframe src="{url}" width="100%" height="600"></iframe>'
else:
return "<p>Website not found.</p>"
# Define the Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# Website Selector Tool")
gr.Markdown("""
This tool allows you to select and interact with a website in an embedded viewer.
""")
# Dropdown for selecting a website
website_name = gr.Dropdown(list(WEBSITES.keys()), label="Select a Website")
# Button to trigger website embedding
open_btn = gr.Button("Open Website")
# HTML component to display the selected website in an iframe
result = gr.HTML(label="Interactive Website Viewer")
# Click event to retrieve the website and embed it in the iframe
open_btn.click(open_website, inputs=website_name, outputs=result)
# Launch the Gradio interface publicly
demo.launch(share=True)