Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
"
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
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):
|