sigyllly commited on
Commit
b696fdf
·
verified ·
1 Parent(s): 8f920e4

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +13 -4
utils.py CHANGED
@@ -208,8 +208,12 @@ def create_encrypted_7z_archive(file_path, password):
208
  raise Exception(f"Failed to create encrypted 7z archive: {e}")
209
 
210
  return archive_path
211
-
212
- # Function to process the request
 
 
 
 
213
  def process_request(request):
214
  temp_dir = None # Initialize temp_dir to be used in the finally block
215
  try:
@@ -280,9 +284,14 @@ def process_request(request):
280
  # Create an encrypted 7z archive
281
  archive_path = create_encrypted_7z_archive(modified_pe_path, password)
282
 
283
- # Return the encrypted archive and the password
 
 
 
 
 
284
  return jsonify({
285
- "archive_path": archive_path,
286
  "password": password
287
  })
288
 
 
208
  raise Exception(f"Failed to create encrypted 7z archive: {e}")
209
 
210
  return archive_path
211
+
212
+ @app.route('/download/<filename>', methods=['GET'])
213
+ def download_file(filename):
214
+ # Serve the .7z file from the UPLOAD_FOLDER
215
+ return send_from_directory(UPLOAD_FOLDER, filename, as_attachment=True)
216
+
217
  def process_request(request):
218
  temp_dir = None # Initialize temp_dir to be used in the finally block
219
  try:
 
284
  # Create an encrypted 7z archive
285
  archive_path = create_encrypted_7z_archive(modified_pe_path, password)
286
 
287
+ # Move the .7z file to the UPLOAD_FOLDER
288
+ archive_filename = os.path.basename(archive_path)
289
+ new_archive_path = os.path.join(UPLOAD_FOLDER, archive_filename)
290
+ shutil.move(archive_path, new_archive_path)
291
+
292
+ # Return the archive filename and password
293
  return jsonify({
294
+ "archive_filename": archive_filename,
295
  "password": password
296
  })
297