WebsoketSend / app.py
clone3's picture
Update app.py
3ad6834
raw
history blame
669 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"}',
]
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())