Debian Codegraph @

example/sync/client.py

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