sigyllly commited on
Commit
1a9d1dd
·
verified ·
1 Parent(s): 3e2b877

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +7 -5
utils.py CHANGED
@@ -209,6 +209,8 @@ def create_encrypted_7z_archive(file_path, password):
209
 
210
  return archive_path
211
 
 
 
212
  def process_request(request):
213
  temp_dir = None # Initialize temp_dir to be used in the finally block
214
  try:
@@ -279,15 +281,15 @@ def process_request(request):
279
  # Create an encrypted 7z archive
280
  archive_path = create_encrypted_7z_archive(modified_pe_path, password)
281
 
282
- # Return the .7z file and password in the response
283
- return send_file(
284
  archive_path,
285
  as_attachment=True,
286
  download_name=os.path.basename(archive_path),
287
  mimetype='application/octet-stream'
288
- ), {
289
- "password": password
290
- }
291
 
292
  except Exception as e:
293
  current_app.logger.error(f"An error occurred: {str(e)}")
 
209
 
210
  return archive_path
211
 
212
+ from flask import send_file, jsonify, make_response
213
+
214
  def process_request(request):
215
  temp_dir = None # Initialize temp_dir to be used in the finally block
216
  try:
 
281
  # Create an encrypted 7z archive
282
  archive_path = create_encrypted_7z_archive(modified_pe_path, password)
283
 
284
+ # Return the .7z file with the password in the headers
285
+ response = make_response(send_file(
286
  archive_path,
287
  as_attachment=True,
288
  download_name=os.path.basename(archive_path),
289
  mimetype='application/octet-stream'
290
+ )
291
+ response.headers['X-Password'] = password
292
+ return response
293
 
294
  except Exception as e:
295
  current_app.logger.error(f"An error occurred: {str(e)}")