Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -209,22 +209,37 @@ def main():
|
|
209 |
all_files = glob.glob("*.*")
|
210 |
all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
211 |
all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
212 |
-
|
213 |
for file in all_files:
|
214 |
os.remove(file)
|
215 |
st.experimental_rerun()
|
216 |
|
217 |
if st.sidebar.button("⬇️ Download All"):
|
218 |
# Compose all_files
|
219 |
-
all_files = glob.glob("*.*")
|
220 |
-
all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
221 |
-
all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
# Expander for showing URL history and download links
|
230 |
with st.expander("URL History and Downloaded Files"):
|
|
|
209 |
all_files = glob.glob("*.*")
|
210 |
all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
211 |
all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
212 |
+
|
213 |
for file in all_files:
|
214 |
os.remove(file)
|
215 |
st.experimental_rerun()
|
216 |
|
217 |
if st.sidebar.button("⬇️ Download All"):
|
218 |
# Compose all_files
|
219 |
+
#all_files = glob.glob("*.*")
|
220 |
+
#all_files = [file for file in all_files if len(os.path.splitext(file)[0]) >= 10] # exclude files with short names
|
221 |
+
#all_files.sort(key=lambda x: (os.path.splitext(x)[1], x), reverse=True) # sort by file type and file name in descending order
|
222 |
+
for subdir in history.values(): # go through each download directory
|
223 |
+
#show_download_links(subdir)
|
224 |
+
global file_sequence_numbers
|
225 |
+
for file in list_files(subdir): # go through each file that was downloaded
|
226 |
+
file_path = os.path.join(subdir, file)
|
227 |
+
if file_path not in file_sequence_numbers:
|
228 |
+
file_sequence_numbers[file_path] = 1
|
229 |
+
else:
|
230 |
+
file_sequence_numbers[file_path] += 1
|
231 |
+
sequence_number = file_sequence_numbers[file_path]
|
232 |
+
if os.path.isfile(file_path):
|
233 |
+
st.markdown(get_download_link(file_path), unsafe_allow_html=True)
|
234 |
+
show_file_operations(file_path, sequence_number)
|
235 |
+
else:
|
236 |
+
st.write(f"File not found: {file}")
|
237 |
+
zip_file = create_zip_of_files(list_files(subdir))
|
238 |
+
#with open(file, "rb") as f:
|
239 |
+
# bytes = f.read()
|
240 |
+
# b64 = base64.b64encode(bytes).decode()
|
241 |
+
# href = f'<a href="data:file/octet-stream;base64,{b64}" download=\'{os.path.basename(file)}\'>Download: {os.path.basename(file)}</a>'
|
242 |
+
st.sidebar.markdown(get_zip_download_link(zip_file), unsafe_allow_html=True)
|
243 |
|
244 |
# Expander for showing URL history and download links
|
245 |
with st.expander("URL History and Downloaded Files"):
|