Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,12 +66,16 @@ def get_download_link(file):
|
|
| 66 |
href = f'<a href="data:file/octet-stream;base64,{b64}" download=\'{os.path.basename(file)}\'>download the latest revision</a>'
|
| 67 |
return href
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
def show_file_operations(file_path):
|
| 70 |
-
# Unique keys for each file and operation based on their path
|
| 71 |
-
edit_button_key = f"edit_button_{file_path}"
|
| 72 |
-
save_button_key = f"save_button_{file_path}"
|
| 73 |
-
delete_button_key = f"delete_button_{file_path}"
|
| 74 |
-
content_key = f"content_{file_path}"
|
| 75 |
|
| 76 |
# Start Edit operation
|
| 77 |
if st.button(f"✏️ Edit {os.path.basename(file_path)}", key=edit_button_key):
|
|
@@ -101,6 +105,7 @@ def show_file_operations(file_path):
|
|
| 101 |
st.session_state.pop(edit_button_key, None)
|
| 102 |
st.session_state.pop(content_key, None)
|
| 103 |
|
|
|
|
| 104 |
def main():
|
| 105 |
st.sidebar.title('Web Datasets Bulk Downloader')
|
| 106 |
url = st.sidebar.text_input('Please enter a Web URL to bulk download text and files')
|
|
|
|
| 66 |
href = f'<a href="data:file/octet-stream;base64,{b64}" download=\'{os.path.basename(file)}\'>download the latest revision</a>'
|
| 67 |
return href
|
| 68 |
|
| 69 |
+
def generate_hash_key(path):
|
| 70 |
+
"""Generate a unique hash key for a given file path."""
|
| 71 |
+
return hashlib.md5(path.encode()).hexdigest()
|
| 72 |
+
|
| 73 |
def show_file_operations(file_path):
|
| 74 |
+
# Unique hash keys for each file and operation based on their path
|
| 75 |
+
edit_button_key = f"edit_button_{generate_hash_key(file_path)}"
|
| 76 |
+
save_button_key = f"save_button_{generate_hash_key(file_path)}"
|
| 77 |
+
delete_button_key = f"delete_button_{generate_hash_key(file_path)}"
|
| 78 |
+
content_key = f"content_{generate_hash_key(file_path)}"
|
| 79 |
|
| 80 |
# Start Edit operation
|
| 81 |
if st.button(f"✏️ Edit {os.path.basename(file_path)}", key=edit_button_key):
|
|
|
|
| 105 |
st.session_state.pop(edit_button_key, None)
|
| 106 |
st.session_state.pop(content_key, None)
|
| 107 |
|
| 108 |
+
|
| 109 |
def main():
|
| 110 |
st.sidebar.title('Web Datasets Bulk Downloader')
|
| 111 |
url = st.sidebar.text_input('Please enter a Web URL to bulk download text and files')
|