Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -118,10 +118,20 @@ def delete_path(path):
|
|
118 |
if os.path.isfile(path):
|
119 |
os.remove(path)
|
120 |
filename = os.path.basename(path)
|
|
|
|
|
|
|
|
|
|
|
121 |
gr.Info(f"The file {filename} has been deleted successfully.")
|
122 |
elif os.path.isdir(path):
|
123 |
shutil.rmtree(path)
|
124 |
foldername = os.path.basename(path)
|
|
|
|
|
|
|
|
|
|
|
125 |
gr.Info(f"The directory {foldername} has been deleted successfully.")
|
126 |
else:
|
127 |
print(f"The path {path} does not exist.")
|
@@ -130,6 +140,7 @@ def delete_path(path):
|
|
130 |
print(f"An error occurred while deleting {path}: {e}")
|
131 |
gr.Warning("Invalid action.")
|
132 |
|
|
|
133 |
def delete_files(path, secret):
|
134 |
if secret == os.environ.get('SECRET_KEY'):
|
135 |
for paths in path:
|
|
|
118 |
if os.path.isfile(path):
|
119 |
os.remove(path)
|
120 |
filename = os.path.basename(path)
|
121 |
+
root_directory = '/tmp/gradio'
|
122 |
+
folder_contents_dict = get_folder_contents_dict(root_directory)
|
123 |
+
base_url = "https://abhicodes-file-sharing-system.hf.space/file=/tmp/gradio"
|
124 |
+
urls = [f"{base_url}/{folder}/{file}" for folder, files in folder_contents_dict.items() for file in files]
|
125 |
+
references_collection.update_one({"_id": ObjectId('66531a797cbaa19ba4e441c5')}, {"$set": {"urls": urls}})
|
126 |
gr.Info(f"The file {filename} has been deleted successfully.")
|
127 |
elif os.path.isdir(path):
|
128 |
shutil.rmtree(path)
|
129 |
foldername = os.path.basename(path)
|
130 |
+
root_directory = '/tmp/gradio'
|
131 |
+
folder_contents_dict = get_folder_contents_dict(root_directory)
|
132 |
+
base_url = "https://abhicodes-file-sharing-system.hf.space/file=/tmp/gradio"
|
133 |
+
urls = [f"{base_url}/{folder}/{file}" for folder, files in folder_contents_dict.items() for file in files]
|
134 |
+
references_collection.update_one({"_id": ObjectId('66531a797cbaa19ba4e441c5')}, {"$set": {"urls": urls}})
|
135 |
gr.Info(f"The directory {foldername} has been deleted successfully.")
|
136 |
else:
|
137 |
print(f"The path {path} does not exist.")
|
|
|
140 |
print(f"An error occurred while deleting {path}: {e}")
|
141 |
gr.Warning("Invalid action.")
|
142 |
|
143 |
+
|
144 |
def delete_files(path, secret):
|
145 |
if secret == os.environ.get('SECRET_KEY'):
|
146 |
for paths in path:
|