Ramesh-vani commited on
Commit
656d9ed
·
verified ·
1 Parent(s): d56852a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -40,17 +40,18 @@ class FileHandler(FileSystemEventHandler):
40
  "name": event.src_path.split('/')[-1]
41
  }
42
  websockets.broadcast(self.connected,json.dumps(new_event))
43
- with open(event.src_path, 'r', encoding='utf-8') as file:
44
- content = file.read()
45
- print(f'File {event.src_path} has been created.')
46
- new_event = {
47
- "type": "file-create",
48
- "content": content,
49
- "path": event.src_path,
50
- "name": event.src_path.split('/')[-1]
51
- }
52
- print(new_event)
53
- websockets.broadcast(self.connected,json.dumps(new_event))
 
54
  # websockets.broadcast(self.connected,f'File {event.src_path} has been created.')
55
 
56
  def on_deleted(self, event):
 
40
  "name": event.src_path.split('/')[-1]
41
  }
42
  websockets.broadcast(self.connected,json.dumps(new_event))
43
+ else:
44
+ with open(event.src_path, 'r', encoding='utf-8') as file:
45
+ content = file.read()
46
+ print(f'File {event.src_path} has been created.')
47
+ new_event = {
48
+ "type": "file-create",
49
+ "content": content,
50
+ "path": event.src_path,
51
+ "name": event.src_path.split('/')[-1]
52
+ }
53
+ print(new_event)
54
+ websockets.broadcast(self.connected,json.dumps(new_event))
55
  # websockets.broadcast(self.connected,f'File {event.src_path} has been created.')
56
 
57
  def on_deleted(self, event):