Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
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())
|