Ramesh-vani commited on
Commit
64e6a96
·
verified ·
1 Parent(s): 38322b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -16,6 +16,25 @@ JOIN = {}
16
 
17
  WATCH = {}
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  async def create_file(websocket, project_name, path, connected):
20
  file_path = os.path.join(os.getcwd(), 'projects', project_name, path)
21
  # Create the file
 
16
 
17
  WATCH = {}
18
 
19
+ async def delete_item(websocket, project_name, path, connected):
20
+ try:
21
+
22
+ item_path = path
23
+
24
+ if os.path.exists(item_path):
25
+ if os.path.isdir(item_path):
26
+ shutil.rmtree(item_path) # Remove the directory and its contents
27
+ elif os.path.isfile(item_path):
28
+ os.remove(item_path) # Remove the file
29
+
30
+ return jsonify({'success': True})
31
+ else:
32
+ print('item not found')
33
+ return jsonify({'success': False, 'message': 'Item not found'})
34
+ except Exception as e:
35
+ print(e)
36
+ return jsonify({'success': False, 'message': str(e)})
37
+
38
  async def create_file(websocket, project_name, path, connected):
39
  file_path = os.path.join(os.getcwd(), 'projects', project_name, path)
40
  # Create the file