Spaces:
Running
Running
lovodkin93
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -9,18 +9,22 @@ def show_html_in_iframe(page_idx, html_files, curr_split):
|
|
9 |
return iframe_html
|
10 |
|
11 |
with gr.Blocks() as demo:
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
24 |
|
25 |
# Display the interface
|
26 |
demo.launch()
|
|
|
9 |
return iframe_html
|
10 |
|
11 |
with gr.Blocks() as demo:
|
12 |
+
with gr.Row():
|
13 |
+
instance_type_dropdown = gr.Dropdown(choices=['test', 'dev'], label='Instance Type')
|
14 |
+
slider = gr.Slider(minimum=0, step=1, label='Data Instance')
|
15 |
+
|
16 |
+
# Dynamic update of slider based on instance type
|
17 |
+
def update_slider_options(instance_type):
|
18 |
+
html_files = get_html_files_list(instance_type)
|
19 |
+
slider.update(options=list(range(len(html_files))))
|
20 |
+
return len(html_files) - 1 # Return maximum index as new value for slider
|
21 |
+
|
22 |
+
# Link dropdown change to updating slider options
|
23 |
+
instance_type_dropdown.change(fn=update_slider_options, inputs=instance_type_dropdown, outputs=slider)
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
# Create the Gradio interface
|
27 |
+
slider.release(show_html_in_iframe, inputs=[slider, html_files, instance_type_dropdown], outputs=[gr.HTML()], api_name="HTML Viewer with Event Listeners")
|
28 |
|
29 |
# Display the interface
|
30 |
demo.launch()
|