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