Spaces:
Running
Running
File size: 1,377 Bytes
1974b02 2499414 281253d 172c8f9 281253d 172c8f9 a3aa13c 281253d ab1c482 172c8f9 ab1c482 cbee98e ab1c482 81b6700 172c8f9 281253d a4e991b 33d5737 86c3edd 281253d 81b6700 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
import os
# Function to show HTML content using an iframe
def show_html_in_iframe(page_idx):
# html_files = get_html_files_list(curr_split)
# Construct the URL using the selected index
url = f'https://wmtis.s3.eu-west-1.amazonaws.com/test/{html_files[page_idx]}'
iframe_html = f'<iframe src="{url}" width="100%" height="1000"></iframe>'
return iframe_html
# Example lists of HTML files for 'test' and 'dev' instances
# train_html_files = [f for f in os.listdir(os.path.join("html_files", "train")) if f.endswith('.html')]
# dev_html_files = [f for f in os.listdir(os.path.join("html_files", "dev")) if f.endswith('.html')]
html_files = [f for f in os.listdir(os.path.join("html_files", "test")) if f.endswith('.html')]
# Function to return the appropriate list based on instance type
def get_html_files_list(instance_type):
if instance_type == 'train':
return train_html_files
elif instance_type == 'dev':
return dev_html_files
elif instance_type == 'test':
return test_html_files
with gr.Blocks() as demo:
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()
|