multi delete
All checks were successful
Docker Deploy / build-and-deploy (push) Successful in 6s

This commit is contained in:
sam
2026-02-06 11:21:42 +00:00
parent 82c7457ed1
commit 89d1b15543
2 changed files with 117 additions and 12 deletions

31
app.py
View File

@@ -113,6 +113,37 @@ def delete_file():
except Exception as e:
return jsonify({"error": str(e)}), 500
@app.route('/api/delete_multiple', methods=['DELETE'])
def delete_multiple_files():
"""Deletes multiple files."""
data = request.get_json()
paths = data.get('paths', [])
if not paths:
return jsonify({"error": "No file paths provided"}), 400
errors = []
success_count = 0
for path in paths:
if not path or not os.path.exists(path):
errors.append({"path": path, "error": "File not found"})
continue
try:
if os.path.isdir(path):
errors.append({"path": path, "error": "Cannot delete directories"})
else:
os.remove(path)
success_count += 1
except Exception as e:
errors.append({"path": path, "error": str(e)})
if not errors:
return jsonify({"success": True, "message": f"{success_count} files deleted."})
else:
return jsonify({"success": False, "error": "Some files could not be deleted", "details": errors}), 500
if __name__ == '__main__':
# Run on localhost
print("Starting File Explorer on http://127.0.0.1:5005")