Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,20 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import websockets
|
3 |
import asyncio
|
|
|
4 |
|
5 |
-
async def
|
6 |
-
uri = "
|
7 |
async with websockets.connect(uri) as websocket:
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
fn=predict,
|
20 |
-
inputs=gr.Textbox(),
|
21 |
-
outputs="text",
|
22 |
-
live=True,
|
23 |
-
)
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
1 |
import asyncio
|
2 |
+
import websockets
|
3 |
|
4 |
+
async def hello():
|
5 |
+
uri = "ws://localhost:8765"
|
6 |
async with websockets.connect(uri) as websocket:
|
7 |
+
#messages = ["{"data":["spider",1683852825,8,4,true],"event_data":null,"fn_index":2,"session_hash":"kb46puzhzr"}", "Second message"]
|
8 |
+
messages = [
|
9 |
+
'{"fn_index":2,"session_hash":"kb46puzhzr"}',
|
10 |
+
'{"data":["spider",1683852825,8,4,true],"event_data":null,"fn_index":2,"session_hash":"kb46puzhzr"}'
|
11 |
+
]
|
12 |
+
for message in messages:
|
13 |
+
print(f"Sending: {message}")
|
14 |
+
await websocket.send(message)
|
15 |
+
|
16 |
+
response = await websocket.recv()
|
17 |
+
print(f"Received: {response}")
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
if __name__ == "__main__":
|
20 |
+
asyncio.run(hello())
|