clone3 commited on
Commit
e00660b
1 Parent(s): 2341a50

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -23
app.py CHANGED
@@ -4,32 +4,27 @@ import websockets
4
  async def send_wss_request():
5
  uri = "wss://clone3-imagex-clone-advance.hf.space/queue/join"
6
 
7
- async with websockets.connect(uri) as websocket:
8
- # Receive the response
9
- response = await websocket.recv()
10
- print(f"Received: {response}")
 
 
11
 
12
- # Send a message
13
- message = '{"fn_index":2,"session_hash":"kb46puzhzr"}'
14
- await websocket.send(message)
15
- print(f"Sent: {message}")
16
 
17
- # Receive the response
18
- response = await websocket.recv()
19
- print(f"Received: {response}")
20
 
21
- # Receive the response
22
- response = await websocket.recv()
23
- print(f"Received: {response}")
24
-
25
- # Send a message
26
- message = '{"data":["spider man",1683852825,8,4,true],"event_data":null,"fn_index":2,"session_hash":"kb46puzhzr"}'
27
- await websocket.send(message)
28
- print(f"Sent: {message}")
29
-
30
- # Receive the response
31
- response = await websocket.recv()
32
- print(f"Received: {response}")
33
 
 
 
 
34
  # Run the event loop
35
  asyncio.get_event_loop().run_until_complete(send_wss_request())
 
4
  async def send_wss_request():
5
  uri = "wss://clone3-imagex-clone-advance.hf.space/queue/join"
6
 
7
+ while True:
8
+ try:
9
+ async with websockets.connect(uri) as websocket:
10
+ # Receive the response
11
+ response = await websocket.recv()
12
+ print(f"Received: {response}")
13
 
14
+ # Send a message
15
+ message = '{"fn_index":2,"session_hash":"kb46puzhzr"}'
16
+ await websocket.send(message)
17
+ print(f"Sent: {message}")
18
 
19
+ # Receive the response
20
+ response = await websocket.recv()
21
+ print(f"Received: {response}")
22
 
23
+ except websockets.exceptions.ConnectionClosed:
24
+ print("Connection closed. Reconnecting in 30 minutes.")
 
 
 
 
 
 
 
 
 
 
25
 
26
+ # Sleep for 30 minutes before the next iteration
27
+ await asyncio.sleep(30 * 60)
28
+
29
  # Run the event loop
30
  asyncio.get_event_loop().run_until_complete(send_wss_request())