umarigan commited on
Commit
8315f3e
1 Parent(s): beac33f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -80,21 +80,35 @@ def generate_plot(query, pdf_file):
80
  logging.info("Plot saved to file.")
81
  return temp_file.name
82
 
83
- def gradio_interface(pdf_file, query):
84
  logging.info("Gradio interface called.")
85
  plot_path = generate_plot(query, pdf_file)
86
  with open(plot_path, "r") as f:
87
  html_content = f.read()
88
  logging.info("Returning HTML content.")
89
  return html_content
 
 
 
 
 
 
 
 
 
 
 
 
90
 
 
91
  iface = gr.Interface(
92
  fn=gradio_interface,
93
  inputs=[gr.File(label="Upload PDF"), gr.Textbox(label="Query")],
94
- outputs=gr.HTML(label="Visualization"),
95
  title="PDF Content Visualizer",
96
  description="Upload a PDF and enter a query to visualize the content."
97
  )
98
 
 
99
  if __name__ == "__main__":
100
  iface.launch()
 
80
  logging.info("Plot saved to file.")
81
  return temp_file.name
82
 
83
+ def gradio_interface_o(pdf_file, query):
84
  logging.info("Gradio interface called.")
85
  plot_path = generate_plot(query, pdf_file)
86
  with open(plot_path, "r") as f:
87
  html_content = f.read()
88
  logging.info("Returning HTML content.")
89
  return html_content
90
+ def gradio_interface(pdf_file, query):
91
+ logging.info("Gradio interface called.")
92
+ plot_path = generate_plot(query, pdf_file)
93
+
94
+ # Assuming 'plot_path' can be accessed via a URL 'plot_url'
95
+ plot_url = f"http://yourserver.com/path/to/{os.path.basename(plot_path)}"
96
+ logging.info(f"Plot URL: {plot_url}")
97
+
98
+ # Return an iframe pointing to the plot URL
99
+ iframe_html = f'<iframe src="{plot_url}" width="100%" height="700"></iframe>'
100
+ logging.info("Returning iframe HTML content.")
101
+ return iframe_html
102
 
103
+ # Update the outputs to gr.HTML() if it's not already
104
  iface = gr.Interface(
105
  fn=gradio_interface,
106
  inputs=[gr.File(label="Upload PDF"), gr.Textbox(label="Query")],
107
+ outputs=gr.HTML(),
108
  title="PDF Content Visualizer",
109
  description="Upload a PDF and enter a query to visualize the content."
110
  )
111
 
112
+
113
  if __name__ == "__main__":
114
  iface.launch()