gschleusner commited on
Commit
d2b84a1
·
1 Parent(s): b874e9b

save file to template location so server can download

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -4,7 +4,7 @@ import zipfile
4
  import io
5
  import os
6
  import tempfile
7
- from datetime import datetime # Import to get current date
8
 
9
  # Helper function to find color areas
10
  def find_color_areas(page, target_color, tolerance=30):
@@ -143,13 +143,16 @@ def process_pdf_files(input_pdfs, selected_color_comment_indices, tolerance, cus
143
  # Generate the current date string
144
  current_date = datetime.now().strftime("%Y-%m-%d")
145
 
146
- # Create a temporary file with a custom name including the date
147
- temp_filename = f"CoordinationPDFS_{current_date}.zip"
148
- with tempfile.NamedTemporaryFile(delete=False, suffix=".zip", prefix="CoordinationPDFS_", dir=".") as tmp_file:
 
 
 
 
149
  tmp_file.write(zip_in_memory.read())
150
- temp_file_name = tmp_file.name # Store the temp file name
151
-
152
- return temp_file_name # Return the path to the temp file
153
 
154
  # Define the Gradio interface
155
  interface = gr.Interface(
 
4
  import io
5
  import os
6
  import tempfile
7
+ from datetime import datetime
8
 
9
  # Helper function to find color areas
10
  def find_color_areas(page, target_color, tolerance=30):
 
143
  # Generate the current date string
144
  current_date = datetime.now().strftime("%Y-%m-%d")
145
 
146
+ # Create an output directory if it doesn't exist
147
+ output_dir = "./output"
148
+ os.makedirs(output_dir, exist_ok=True)
149
+
150
+ # Create a temporary file in the output directory with a custom name including the date
151
+ temp_filename = os.path.join(output_dir, f"CoordinationPDFS_{current_date}.zip")
152
+ with open(temp_filename, 'wb') as tmp_file:
153
  tmp_file.write(zip_in_memory.read())
154
+
155
+ return temp_filename # Return the path to the temp file
 
156
 
157
  # Define the Gradio interface
158
  interface = gr.Interface(