Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -60,6 +60,29 @@ def save_all_images(images):
|
|
60 |
|
61 |
return zip_filename, download_link
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
# Function to clear all image files
|
65 |
def clear_all_images():
|
|
|
60 |
|
61 |
return zip_filename, download_link
|
62 |
|
63 |
+
|
64 |
+
def create_zip_of_files(files):
|
65 |
+
"""
|
66 |
+
Create a zip file from a list of files.
|
67 |
+
"""
|
68 |
+
zip_name = "all_files.zip"
|
69 |
+
with zipfile.ZipFile(zip_name, 'w') as zipf:
|
70 |
+
for file in files:
|
71 |
+
zipf.write(file)
|
72 |
+
return zip_name
|
73 |
+
|
74 |
+
|
75 |
+
def get_zip_download_link(zip_file):
|
76 |
+
"""
|
77 |
+
Generate a link to download the zip file.
|
78 |
+
"""
|
79 |
+
with open(zip_file, 'rb') as f:
|
80 |
+
data = f.read()
|
81 |
+
b64 = base64.b64encode(data).decode()
|
82 |
+
href = f'<a href="data:application/zip;base64,{b64}" download="{zip_file}">Download All</a>'
|
83 |
+
return href
|
84 |
+
|
85 |
+
|
86 |
|
87 |
# Function to clear all image files
|
88 |
def clear_all_images():
|