Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,18 +2,27 @@ import websockets
|
|
2 |
|
3 |
def hello():
|
4 |
uri = "ws://localhost:8765"
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
if __name__ == "__main__":
|
19 |
hello()
|
|
|
2 |
|
3 |
def hello():
|
4 |
uri = "ws://localhost:8765"
|
5 |
+
|
6 |
+
# Connect to the WebSocket
|
7 |
+
websocket = websockets.connect(uri)
|
8 |
+
|
9 |
+
messages = [
|
10 |
+
'{"data":["spider",1683852825,8,4,true],"event_data":null,"fn_index":2,"session_hash":"kb46puzhzr"}',
|
11 |
+
'{"data":["spider",1683852825,8,4,true],"event_data":null,"fn_index":2,"session_hash":"kb46puzhzr"}'
|
12 |
+
]
|
13 |
|
14 |
+
for message in messages:
|
15 |
+
print(f"Sending: {message}")
|
16 |
+
|
17 |
+
# Send the message
|
18 |
+
websocket.send(message)
|
19 |
+
|
20 |
+
# Receive the response
|
21 |
+
response = websocket.recv()
|
22 |
+
print(f"Received: {response}")
|
23 |
+
|
24 |
+
# Close the WebSocket connection
|
25 |
+
websocket.close()
|
26 |
|
27 |
if __name__ == "__main__":
|
28 |
hello()
|