Ramesh-vani commited on
Commit
1e95249
·
verified ·
1 Parent(s): 857b6ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -16,28 +16,28 @@ JOIN = {}
16
 
17
  WATCH = {}
18
 
19
- async def create_file(websocket, project_name, path):
20
  file_path = os.path.join(os.getcwd(), 'projects', project_name, path)
21
  # Create the file
22
  with open(file_path, 'w'):
23
  pass
24
- await websocket.send(f"file created to {file_path}")
25
 
26
- async def create_folder(websocket, project_name, path):
27
  folder_path = os.path.join(os.getcwd(), 'projects', project_name, path)
28
  # Create the folder
29
  os.makedirs(folder_path)
30
- await websocket.send(f"folder created to {folder_path}")
31
 
32
- async def wirte_file(websocket, project_name, path, content):
33
  try:
34
  file_path = os.path.join(os.getcwd(), 'projects', project_name, path)
35
  file_content = content
36
  with open(file_path, 'w', encoding='utf-8') as file:
37
  file.write(file_content)
38
- await websocket.send(f"Content written to {file_path}")
39
  except FileNotFoundError as e:
40
- await websocket.send(f"Error: {str(e)}")
41
 
42
 
43
  async def execute_command(websocket, project_name, command, connected):
@@ -185,16 +185,16 @@ async def exe(websocket,connected):
185
  await execute_command(websocket, event["project_name"], event["command"], connected)
186
  elif "write" in event:
187
 
188
- await wirte_file(websocket, event["project_name"], event["path"], event["content"])
189
  elif "create" in event:
190
 
191
- await wirte_file(websocket, event["project_name"], event["path"], event["content"]) #Todo
192
  elif "delete" in event:
193
 
194
- await wirte_file(websocket, event["project_name"], event["path"], event["content"]) #Todo
195
  elif "rename" in event:
196
 
197
- await wirte_file(websocket, event["project_name"], event["path"], event["content"]) #Todo
198
 
199
  else:
200
  # First player starts a new game.
 
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
22
  with open(file_path, 'w'):
23
  pass
24
+ websockets.broadcast(connected,f"file created to {file_path}")
25
 
26
+ async def create_folder(websocket, project_name, path, connected):
27
  folder_path = os.path.join(os.getcwd(), 'projects', project_name, path)
28
  # Create the folder
29
  os.makedirs(folder_path)
30
+ websockets.broadcast(connected,f"folder created to {folder_path}")
31
 
32
+ async def wirte_file(websocket, project_name, path, content, connected):
33
  try:
34
  file_path = os.path.join(os.getcwd(), 'projects', project_name, path)
35
  file_content = content
36
  with open(file_path, 'w', encoding='utf-8') as file:
37
  file.write(file_content)
38
+ websockets.broadcast(connected,f"Content written to {file_path}")
39
  except FileNotFoundError as e:
40
+ websockets.broadcast(connected,f"Error: {str(e)}")
41
 
42
 
43
  async def execute_command(websocket, project_name, command, connected):
 
185
  await execute_command(websocket, event["project_name"], event["command"], connected)
186
  elif "write" in event:
187
 
188
+ await wirte_file(websocket, event["project_name"], event["path"], event["content"], connected)
189
  elif "create" in event:
190
 
191
+ await wirte_file(websocket, event["project_name"], event["path"], event["content"], connected) #Todo
192
  elif "delete" in event:
193
 
194
+ await wirte_file(websocket, event["project_name"], event["path"], event["content"], connected) #Todo
195
  elif "rename" in event:
196
 
197
+ await wirte_file(websocket, event["project_name"], event["path"], event["content"], connected) #Todo
198
 
199
  else:
200
  # First player starts a new game.