example/legacy/basic_auth_client.py
raw| 1 | #!/usr/bin/env python |
| 2 | |
| 3 | # WS client example with HTTP Basic Authentication |
| 4 | |
| 5 | import asyncio |
| 6 | |
| 7 | from websockets.legacy.client import connect |
| 8 | |
| 9 | async def hello(): |
| 10 | uri = "ws://mary:p@ssw0rd@localhost:8765" |
| 11 | async with connect(uri) as websocket: |
| 12 | greeting = await websocket.recv() |
| 13 | print(greeting) |
| 14 | |
| 15 | asyncio.run(hello()) |