FuseReviews / app.py
lovodkin93's picture
Update app.py
3ea3175 verified
import gradio as gr
import os
# Function to show HTML content using an iframe
def show_html_in_iframe(page_idx):
# Construct the URL using the selected index
# url = f'https://wmtis.s3.eu-west-1.amazonaws.com/test/{html_files[page_idx]}'
url = f'https://fusereviews.github.io/multi-review-fusion-in-context/dataset_htmls/train/{html_files[page_idx]}'
iframe_html = f'<iframe src="{url}" width="100%" height="1000"></iframe>'
return iframe_html
# Path to the directory containing HTML files
html_files_path = os.path.join("html_files", "train")
html_files = [f for f in os.listdir(html_files_path) if f.endswith('.html')]
with gr.Blocks() as demo:
# Create a slider component to select the HTML page
slider = gr.Slider(minimum=0, maximum=len(html_files)-1, step=1, label='Data Instance')
# Create the Gradio interface
slider.release(show_html_in_iframe, inputs=[slider], outputs=[gr.HTML()], api_name="HTML Viewer with Event Listeners")
# Display the interface
demo.launch(share=True)