Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from websocket import create_connection
- from contextlib import contextmanager
- @contextmanager
- def web_socket_connection(host):
- ws = create_connection(host)
- yield ws
- ws.close()
- with web_socket_connection("ws://localhost:3071/ws/1") as ws:
- ws.send("Hello, World")
- print(f'Received: {ws.recv()}')
Advertisement
Add Comment
Please, Sign In to add comment