Spaces:
Sleeping
Sleeping
import websockets | |
import asyncio | |
async def hello(): | |
uri = "ws://localhost:8765" | |
# Connect to the WebSocket | |
async with websockets.connect(uri) as websocket: | |
messages = [ | |
'{"fn_index":2,"session_hash":"kb46puzhzr"}', | |
] | |
for message in messages: | |
print(f"Sending: {message}") | |
# Send the message | |
await websocket.send(message) | |
# Receive the response | |
response = await websocket.recv() | |
print(f"Received: {response}") | |
async def main(): | |
await hello() | |
if __name__ == "__main__": | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(main()) |