Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -118,45 +118,11 @@ def show_download_links(subdir):
|
|
| 118 |
sequence_number = file_sequence_numbers[file_path]
|
| 119 |
|
| 120 |
if os.path.isfile(file_path):
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
with col1:
|
| 125 |
-
# Edit button
|
| 126 |
-
edit_key = f"edit_{unique_key}_{sequence_number}"
|
| 127 |
-
if st.button(f"✏️ Edit", key=edit_key):
|
| 128 |
-
with open(file_path, "r") as f:
|
| 129 |
-
file_content = f.read()
|
| 130 |
-
text_area_key = f"text_area_{unique_key}_{sequence_number}"
|
| 131 |
-
file_content = st.text_area("Edit the file content:", value=file_content, height=250, key=text_area_key)
|
| 132 |
-
|
| 133 |
-
with col2:
|
| 134 |
-
# Save button
|
| 135 |
-
save_key = f"save_{unique_key}_{sequence_number}"
|
| 136 |
-
if st.button(f"💾 Save", key=save_key):
|
| 137 |
-
if file_content: # Ensure file_content is not empty
|
| 138 |
-
with open(file_path, "w") as f:
|
| 139 |
-
f.write(file_content)
|
| 140 |
-
st.success(f"File saved!")
|
| 141 |
-
|
| 142 |
-
with col3:
|
| 143 |
-
# Delete button
|
| 144 |
-
delete_key = f"delete_{unique_key}_{sequence_number}"
|
| 145 |
-
if st.button(f"🗑️ Delete", key=delete_key):
|
| 146 |
-
os.remove(file_path)
|
| 147 |
-
st.markdown(f"File deleted!")
|
| 148 |
-
|
| 149 |
-
with col4:
|
| 150 |
-
# Click to download link
|
| 151 |
-
st.markdown(get_download_link(file_path), unsafe_allow_html=True)
|
| 152 |
-
|
| 153 |
-
with col5:
|
| 154 |
-
# Filename
|
| 155 |
-
st.text(os.path.basename(file_path))
|
| 156 |
else:
|
| 157 |
st.write(f"File not found: {file}")
|
| 158 |
|
| 159 |
-
|
| 160 |
def get_download_link(file):
|
| 161 |
with open(file, "rb") as f:
|
| 162 |
bytes = f.read()
|
|
@@ -217,5 +183,4 @@ def main():
|
|
| 217 |
show_download_links(subdir)
|
| 218 |
|
| 219 |
if __name__ == "__main__":
|
| 220 |
-
main()
|
| 221 |
-
|
|
|
|
| 118 |
sequence_number = file_sequence_numbers[file_path]
|
| 119 |
|
| 120 |
if os.path.isfile(file_path):
|
| 121 |
+
st.markdown(get_download_link(file_path), unsafe_allow_html=True)
|
| 122 |
+
show_file_operations(file_path, sequence_number)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
else:
|
| 124 |
st.write(f"File not found: {file}")
|
| 125 |
|
|
|
|
| 126 |
def get_download_link(file):
|
| 127 |
with open(file, "rb") as f:
|
| 128 |
bytes = f.read()
|
|
|
|
| 183 |
show_download_links(subdir)
|
| 184 |
|
| 185 |
if __name__ == "__main__":
|
| 186 |
+
main()
|
|
|