Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,22 +2,25 @@ import gradio as gr
|
|
2 |
import os
|
3 |
|
4 |
# Function to show HTML content using an iframe
|
5 |
-
def show_html_in_iframe(page_idx):
|
6 |
# Construct the URL using the selected index
|
7 |
-
url = f'https://wmtis.s3.eu-west-1.amazonaws.com/
|
8 |
iframe_html = f'<iframe src="{url}" width="100%" height="1000"></iframe>'
|
9 |
return iframe_html
|
10 |
|
11 |
-
# Path to the directory containing HTML files
|
12 |
-
html_files_path = os.path.join("html_files", "test")
|
13 |
-
html_files = [f for f in os.listdir(html_files_path) if f.endswith('.html')]
|
14 |
-
|
15 |
with gr.Blocks() as demo:
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
20 |
-
|
21 |
|
22 |
# Display the interface
|
23 |
demo.launch()
|
|
|
2 |
import os
|
3 |
|
4 |
# Function to show HTML content using an iframe
|
5 |
+
def show_html_in_iframe(page_idx, html_files, curr_split):
|
6 |
# Construct the URL using the selected index
|
7 |
+
url = f'https://wmtis.s3.eu-west-1.amazonaws.com/{curr_split}/{html_files[page_idx]}'
|
8 |
iframe_html = f'<iframe src="{url}" width="100%" height="1000"></iframe>'
|
9 |
return iframe_html
|
10 |
|
|
|
|
|
|
|
|
|
11 |
with gr.Blocks() as demo:
|
12 |
+
# Create a dropdown for selecting the instance type
|
13 |
+
curr_split = gr.Radio(choices=['train', 'dev'], label='split', value='dev')
|
14 |
+
|
15 |
+
# Path to the directory containing HTML files
|
16 |
+
html_files_path = os.path.join("html_files", curr_split)
|
17 |
+
html_files = [f for f in os.listdir(html_files_path) if f.endswith('.html')]
|
18 |
+
|
19 |
+
# Create a slider component to select the HTML page
|
20 |
+
slider = gr.Slider(minimum=0, maximum=len(html_files)-1, step=1, label='Data Instance')
|
21 |
|
22 |
+
# Create the Gradio interface
|
23 |
+
slider.release(show_html_in_iframe, inputs=[slider, html_files, curr_split], outputs=[gr.HTML()], api_name="HTML Viewer with Event Listeners")
|
24 |
|
25 |
# Display the interface
|
26 |
demo.launch()
|