Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,17 +48,22 @@ def list_files(directory_path='.'):
|
|
| 48 |
files = [f for f in os.listdir(directory_path) if os.path.isfile(os.path.join(directory_path, f))]
|
| 49 |
return [f for f in files if f not in EXCLUDED_FILES]
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
def get_download_link(file):
|
| 52 |
with open(file, "rb") as f:
|
| 53 |
bytes = f.read()
|
| 54 |
b64 = base64.b64encode(bytes).decode()
|
| 55 |
-
href = f'<a href="data:file/octet-stream;base64,{b64}" download=\'{
|
| 56 |
return href
|
| 57 |
|
| 58 |
-
def show_download_links(subdir):
|
| 59 |
-
st.write(f'Files for {subdir}:')
|
| 60 |
-
for file in list_files(subdir):
|
| 61 |
-
st.markdown(get_download_link(file), unsafe_allow_html=True)
|
| 62 |
|
| 63 |
def main():
|
| 64 |
st.sidebar.title('Web Datasets Bulk Downloader')
|
|
|
|
| 48 |
files = [f for f in os.listdir(directory_path) if os.path.isfile(os.path.join(directory_path, f))]
|
| 49 |
return [f for f in files if f not in EXCLUDED_FILES]
|
| 50 |
|
| 51 |
+
def show_download_links(subdir):
|
| 52 |
+
st.write(f'Files for {subdir}:')
|
| 53 |
+
for file in list_files(subdir):
|
| 54 |
+
file_path = os.path.join(subdir, file)
|
| 55 |
+
if os.path.isfile(file_path):
|
| 56 |
+
st.markdown(get_download_link(file_path), unsafe_allow_html=True)
|
| 57 |
+
else:
|
| 58 |
+
st.write(f"File not found: {file}")
|
| 59 |
+
|
| 60 |
def get_download_link(file):
|
| 61 |
with open(file, "rb") as f:
|
| 62 |
bytes = f.read()
|
| 63 |
b64 = base64.b64encode(bytes).decode()
|
| 64 |
+
href = f'<a href="data:file/octet-stream;base64,{b64}" download=\'{os.path.basename(file)}\'>Click to download {os.path.basename(file)}</a>'
|
| 65 |
return href
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
def main():
|
| 69 |
st.sidebar.title('Web Datasets Bulk Downloader')
|