histlearn commited on
Commit
6232e4c
verified
1 Parent(s): 6f10e0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -293,31 +293,34 @@ with gr.Blocks(theme=theme) as interface:
293
  excel_files = gr.Files(label="Arraste os arquivos .xlsx aqui", type="binary", file_count="multiple")
294
 
295
  generate_btn = gr.Button("Gerar Relat贸rio", variant="primary") # Destaque no bot茫o
296
- output_html = gr.HTML()
297
-
298
  with gr.Row(): # Crie uma nova linha para os bot玫es
299
  download_html_btn = gr.Button("Baixar Relat贸rio HTML")
300
  download_pdf_btn = gr.Button("Baixar Relat贸rio PDF")
 
301
 
302
  def wrapper(html_file, excel_files):
303
  html_content, html_path, pdf_path = processar_relatorio(html_file, excel_files)
304
- return html_content, html_path, pdf_path
 
 
 
305
 
306
  generate_btn.click(
307
  fn=wrapper,
308
  inputs=[html_file, excel_files],
309
- outputs=[output_html, gr.File(), gr.File()]
310
  )
311
  download_html_btn.click(
312
- fn=None,
313
- inputs=None,
314
- outputs=None,
315
  _js="() => { window.open(document.getElementById('html_output').getAttribute('href'), '_blank'); }"
316
  )
317
  download_pdf_btn.click(
318
- fn=None,
319
- inputs=None,
320
- outputs=None,
321
  _js="() => { window.open(document.getElementById('pdf_output').getAttribute('href'), '_blank'); }"
322
  )
323
  interface.launch()
 
293
  excel_files = gr.Files(label="Arraste os arquivos .xlsx aqui", type="binary", file_count="multiple")
294
 
295
  generate_btn = gr.Button("Gerar Relat贸rio", variant="primary") # Destaque no bot茫o
296
+ output_html = gr.HTML(elem_id="html_output") # Adiciona um ID para refer锚ncia no JavaScript
 
297
  with gr.Row(): # Crie uma nova linha para os bot玫es
298
  download_html_btn = gr.Button("Baixar Relat贸rio HTML")
299
  download_pdf_btn = gr.Button("Baixar Relat贸rio PDF")
300
+ pdf_output = gr.File(label="Download PDF Report", visible=False, elem_id="pdf_output")
301
 
302
  def wrapper(html_file, excel_files):
303
  html_content, html_path, pdf_path = processar_relatorio(html_file, excel_files)
304
+ return {
305
+ output_html: html_content,
306
+ pdf_output: pdf_path, # Retorna o caminho do PDF para o componente oculto
307
+ }
308
 
309
  generate_btn.click(
310
  fn=wrapper,
311
  inputs=[html_file, excel_files],
312
+ outputs=[output_html, pdf_output]
313
  )
314
  download_html_btn.click(
315
+ None,
316
+ [],
317
+ [],
318
  _js="() => { window.open(document.getElementById('html_output').getAttribute('href'), '_blank'); }"
319
  )
320
  download_pdf_btn.click(
321
+ None,
322
+ [],
323
+ [],
324
  _js="() => { window.open(document.getElementById('pdf_output').getAttribute('href'), '_blank'); }"
325
  )
326
  interface.launch()