Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import base64
|
|
| 6 |
from bs4 import BeautifulSoup
|
| 7 |
import hashlib
|
| 8 |
import json
|
|
|
|
| 9 |
|
| 10 |
EXCLUDED_FILES = ['app.py', 'requirements.txt', 'pre-requirements.txt', 'packages.txt', 'README.md','.gitattributes', "backup.py","Dockerfile"]
|
| 11 |
URLS = {
|
|
@@ -53,24 +54,15 @@ def list_files(directory_path='.'):
|
|
| 53 |
|
| 54 |
def show_file_operations(file_path):
|
| 55 |
st.write(f"File: {os.path.basename(file_path)}")
|
| 56 |
-
|
| 57 |
-
# Generate a unique key for each file
|
| 58 |
unique_key = hashlib.md5(file_path.encode()).hexdigest()
|
|
|
|
| 59 |
|
| 60 |
-
# Additional unique identifier for each function call
|
| 61 |
-
unique_call_id = str(uuid.uuid4())
|
| 62 |
-
|
| 63 |
-
# Initialize file_content outside the button blocks
|
| 64 |
file_content = ""
|
| 65 |
|
| 66 |
-
# Create columns for Edit, Save, and Delete buttons
|
| 67 |
col1, col2, col3 = st.columns(3)
|
| 68 |
|
| 69 |
with col1:
|
| 70 |
-
|
| 71 |
-
with open(file_path, "r") as f:
|
| 72 |
-
file_content = f.read()
|
| 73 |
-
file_content = st.text_area("Edit the file content:", value=file_content, height=250, key=f"text_area_{unique_key}_{unique_call_id}")
|
| 74 |
|
| 75 |
with col2:
|
| 76 |
if st.button(f"💾 Save", key=f"save_{unique_key}_{unique_call_id}"):
|
|
|
|
| 6 |
from bs4 import BeautifulSoup
|
| 7 |
import hashlib
|
| 8 |
import json
|
| 9 |
+
import uuid
|
| 10 |
|
| 11 |
EXCLUDED_FILES = ['app.py', 'requirements.txt', 'pre-requirements.txt', 'packages.txt', 'README.md','.gitattributes', "backup.py","Dockerfile"]
|
| 12 |
URLS = {
|
|
|
|
| 54 |
|
| 55 |
def show_file_operations(file_path):
|
| 56 |
st.write(f"File: {os.path.basename(file_path)}")
|
|
|
|
|
|
|
| 57 |
unique_key = hashlib.md5(file_path.encode()).hexdigest()
|
| 58 |
+
unique_call_id = str(uuid.uuid4()) # Use uuid module here
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
file_content = ""
|
| 61 |
|
|
|
|
| 62 |
col1, col2, col3 = st.columns(3)
|
| 63 |
|
| 64 |
with col1:
|
| 65 |
+
# ... Edit button code
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
with col2:
|
| 68 |
if st.button(f"💾 Save", key=f"save_{unique_key}_{unique_call_id}"):
|