Azeez98 commited on
Commit
1a16272
·
verified ·
1 Parent(s): 47db048

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -58,8 +58,14 @@ async def download_dependencies(requirements_file: UploadFile = File(...)):
58
  tar.add(file_path, arcname=file)
59
  tar.add(log_file_path, arcname="download.log")
60
 
 
 
 
61
  # Return the tar file
62
- return StreamingResponse(open(tar_path, "rb"), media_type="application/gzip", headers={"Content-Disposition": f"attachment; filename=dependencies.tar.gz"})
 
 
 
63
 
64
  except subprocess.CalledProcessError as e:
65
  raise HTTPException(status_code=500, detail=f"Error downloading dependencies: {str(e)}")
@@ -71,8 +77,7 @@ async def download_dependencies(requirements_file: UploadFile = File(...)):
71
  if os.path.exists(log_file_path):
72
  os.remove(log_file_path)
73
  if os.path.exists(tar_path):
74
- os.remove(tar_path)
75
-
76
  def download_docker_image(image_name, tag='latest', destination='/tmp/docker-images'):
77
  try:
78
  os.makedirs(destination, exist_ok=True)
 
58
  tar.add(file_path, arcname=file)
59
  tar.add(log_file_path, arcname="download.log")
60
 
61
+ # Get the file size
62
+ file_size = os.path.getsize(tar_path)
63
+
64
  # Return the tar file
65
+ return StreamingResponse(open(tar_path, "rb"), media_type="application/gzip", headers={
66
+ "Content-Disposition": f"attachment; filename=dependencies.tar.gz",
67
+ "Content-Length": str(file_size)
68
+ })
69
 
70
  except subprocess.CalledProcessError as e:
71
  raise HTTPException(status_code=500, detail=f"Error downloading dependencies: {str(e)}")
 
77
  if os.path.exists(log_file_path):
78
  os.remove(log_file_path)
79
  if os.path.exists(tar_path):
80
+ os.remove(tar_path)
 
81
  def download_docker_image(image_name, tag='latest', destination='/tmp/docker-images'):
82
  try:
83
  os.makedirs(destination, exist_ok=True)