clone3 commited on
Commit
9b1afb5
·
1 Parent(s): aea5496

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -21
app.py CHANGED
@@ -1,25 +1,20 @@
1
- import gradio as gr
2
- import websockets
3
  import asyncio
 
4
 
5
- async def send_to_websocket(message):
6
- uri = "wss://clone3-imagex-clone-advance.hf.space/queue/join"
7
  async with websockets.connect(uri) as websocket:
8
- await websocket.send(message)
9
- response = await websocket.recv()
10
- return response
11
-
12
- def predict(input_text):
13
- # You can replace this with your actual machine learning model prediction logic
14
- # For now, we'll just send the input to the WebSocket server and echo the response
15
- response = asyncio.run(send_to_websocket(input_text))
16
- return response
17
-
18
- iface = gr.Interface(
19
- fn=predict,
20
- inputs=gr.Textbox(),
21
- outputs="text",
22
- live=True,
23
- )
24
 
25
- iface.launch()
 
 
 
 
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())