WebsoketSend / app.py
clone3's picture
Update app.py
ec48066
raw
history blame
734 Bytes
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"}',
'{"data":["spider",1683852825,8,4,true],"event_data":null,"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__":
asyncio.run(main())