example/sync/hello.py
raw| 1 | #!/usr/bin/env python |
| 2 | |
| 3 | """Client 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 | websocket.send("Hello world!") |
| 11 | message = websocket.recv() |
| 12 | print(message) |
| 13 | |
| 14 | |
| 15 | if __name__ == "__main__": |
| 16 | hello() |