lovodkin93 commited on
Commit
172c8f9
·
verified ·
1 Parent(s): cbee98e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -19
app.py CHANGED
@@ -2,17 +2,17 @@ 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, curr_split):
6
- html_files = get_html_files_list(curr_split)
7
  # Construct the URL using the selected index
8
- url = f'https://wmtis.s3.eu-west-1.amazonaws.com/{curr_split}/{html_files[page_idx]}'
9
  iframe_html = f'<iframe src="{url}" width="100%" height="1000"></iframe>'
10
  return iframe_html
11
 
12
  # Example lists of HTML files for 'test' and 'dev' instances
13
- train_html_files = [f for f in os.listdir(os.path.join("html_files", "train")) if f.endswith('.html')]
14
- dev_html_files = [f for f in os.listdir(os.path.join("html_files", "dev")) if f.endswith('.html')]
15
- test_html_files = [f for f in os.listdir(os.path.join("html_files", "test")) if f.endswith('.html')]
16
 
17
  # Function to return the appropriate list based on instance type
18
  def get_html_files_list(instance_type):
@@ -25,19 +25,7 @@ def get_html_files_list(instance_type):
25
 
26
 
27
  with gr.Blocks() as demo:
28
- with gr.Row():
29
- instance_type_dropdown = gr.Dropdown(choices=['train', 'dev', 'test'], label='Instance Type')
30
- slider = gr.Slider(minimum=0, step=1, label='Data Instance')
31
-
32
- # Dynamic update of slider based on instance type
33
- def update_slider_options(instance_type):
34
- html_files = get_html_files_list(instance_type)
35
- slider.update(options=list(range(len(html_files))))
36
- return len(html_files) - 1 # Return maximum index as new value for slider
37
-
38
- # Link dropdown change to updating slider options
39
- instance_type_dropdown.change(fn=update_slider_options, inputs=instance_type_dropdown, outputs=slider)
40
-
41
 
42
  # Create the Gradio interface
43
  slider.release(show_html_in_iframe, inputs=[slider, instance_type_dropdown], outputs=[gr.HTML()], api_name="HTML Viewer with Event Listeners")
 
2
  import os
3
 
4
  # Function to show HTML content using an iframe
5
+ def show_html_in_iframe(page_idx):
6
+ # html_files = get_html_files_list(curr_split)
7
  # Construct the URL using the selected index
8
+ url = f'https://wmtis.s3.eu-west-1.amazonaws.com/test/{html_files[page_idx]}'
9
  iframe_html = f'<iframe src="{url}" width="100%" height="1000"></iframe>'
10
  return iframe_html
11
 
12
  # Example lists of HTML files for 'test' and 'dev' instances
13
+ # train_html_files = [f for f in os.listdir(os.path.join("html_files", "train")) if f.endswith('.html')]
14
+ # dev_html_files = [f for f in os.listdir(os.path.join("html_files", "dev")) if f.endswith('.html')]
15
+ html_files = [f for f in os.listdir(os.path.join("html_files", "test")) if f.endswith('.html')]
16
 
17
  # Function to return the appropriate list based on instance type
18
  def get_html_files_list(instance_type):
 
25
 
26
 
27
  with gr.Blocks() as demo:
28
+ slider = gr.Slider(minimum=0, maximum=len(html_files)-1, step=1, label='Data Instance')
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  # Create the Gradio interface
31
  slider.release(show_html_in_iframe, inputs=[slider, instance_type_dropdown], outputs=[gr.HTML()], api_name="HTML Viewer with Event Listeners")