Update app.py
Browse files
app.py
CHANGED
@@ -58,15 +58,21 @@ 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 |
-
|
|
|
62 |
|
63 |
except subprocess.CalledProcessError as e:
|
64 |
raise HTTPException(status_code=500, detail=f"Error downloading dependencies: {str(e)}")
|
65 |
except Exception as e:
|
66 |
raise HTTPException(status_code=500, detail=str(e))
|
67 |
finally:
|
68 |
-
os.
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
70 |
def download_docker_image(image_name, tag='latest', destination='/tmp/docker-images'):
|
71 |
try:
|
72 |
os.makedirs(destination, exist_ok=True)
|
|
|
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)}")
|
66 |
except Exception as e:
|
67 |
raise HTTPException(status_code=500, detail=str(e))
|
68 |
finally:
|
69 |
+
if os.path.exists(tmp_path):
|
70 |
+
os.remove(tmp_path)
|
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)
|