Cachoups commited on
Commit
1e43982
·
verified ·
1 Parent(s): 1e53b66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -47,15 +47,14 @@ def fin_ext_bis(text):
47
  return make_spans(text, results)
48
 
49
  def upload_file_and_update_dropdown(file):
50
- if file is not None:
51
- # Save the file to the upload directory
52
- file_path = os.path.join(PDF_FOLDER, os.path.basename(file))
53
- shutil.copyfile(file.name, file_path)
54
- # Get the updated list of files
55
- files = os.listdir(PDF_FOLDER)
56
- return gr.update(choices=files), gr.update(choices=files)
57
-
58
- return gr.update(choices=[]),gr.Dropdown.update(choices=[])
59
 
60
  def extract_and_paragraph(pdf1, pdf2, paragraph):
61
  if not pdf1 or not pdf2:
@@ -456,7 +455,7 @@ with gr.Blocks(theme='gradio/soft',js=js_func) as demo:
456
  # Upload PDFs
457
  with gr.Column():
458
  gr.Markdown("### Step 1: Upload PDF Files")
459
- upload_button = gr.File(label="Upload files", file_types=[".pdf"])
460
  pdf1 = gr.Dropdown(choices=get_pdf_files(PDF_FOLDER), label="Select PDF 1")
461
  pdf2 = gr.Dropdown(choices=get_pdf_files(PDF_FOLDER), label="Select PDF 2")
462
  upload_button.upload(upload_file_and_update_dropdown, upload_button, [pdf1, pdf2])
 
47
  return make_spans(text, results)
48
 
49
  def upload_file_and_update_dropdown(file):
50
+ for file in files
51
+ if file is not None:
52
+ # Save the file to the upload directory
53
+ file_path = os.path.join(PDF_FOLDER, os.path.basename(file))
54
+ shutil.copyfile(file.name, file_path)
55
+ # Get the updated list of files
56
+ files_list = os.listdir(PDF_FOLDER)
57
+ return gr.update(choices=files_list), gr.update(choices=files_list)
 
58
 
59
  def extract_and_paragraph(pdf1, pdf2, paragraph):
60
  if not pdf1 or not pdf2:
 
455
  # Upload PDFs
456
  with gr.Column():
457
  gr.Markdown("### Step 1: Upload PDF Files")
458
+ upload_button = gr.File(label="Upload files", file_types=[".pdf"], multiple = True)
459
  pdf1 = gr.Dropdown(choices=get_pdf_files(PDF_FOLDER), label="Select PDF 1")
460
  pdf2 = gr.Dropdown(choices=get_pdf_files(PDF_FOLDER), label="Select PDF 2")
461
  upload_button.upload(upload_file_and_update_dropdown, upload_button, [pdf1, pdf2])