Debian Codegraph @

example/asyncio/client.py

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