client.py (398B)
1 #!/usr/bin/env python 2 3 import asyncio 4 import websockets 5 6 async def hello(): 7 uri = "ws://localhost:8765" 8 async with websockets.connect(uri) as websocket: 9 name = input("What's your name? ") 10 11 await websocket.send(name) 12 print(f">>> {name}") 13 14 greeting = await websocket.recv() 15 print(f"<<< {greeting}") 16 17 if __name__ == "__main__": 18 asyncio.run(hello())