()
| 3 | from websockets.sync.client import connect |
| 4 | |
| 5 | def hello(): |
| 6 | uri = "ws://localhost:8765" |
| 7 | with connect(uri) as websocket: |
| 8 | name = input("What's your name? ") |
| 9 | |
| 10 | websocket.send(name) |
| 11 | print(f">>> {name}") |
| 12 | |
| 13 | greeting = websocket.recv() |
| 14 | print(f"<<< {greeting}") |
| 15 | |
| 16 | if __name__ == "__main__": |
| 17 | hello() |