Created
June 19, 2023 12:01
-
-
Save alexhq/ec964b4f9ca9b3b87be17a4073e541af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import asyncio | |
import websockets | |
async def hello(): | |
host = input("Please enter host: ") | |
uri = f"ws://{host}" | |
print(f"uri: {uri}") | |
async with websockets.connect(uri) as websocket: | |
name = input("What's your name? ") | |
await websocket.send(name) | |
print(f">>> {name}") | |
greeting = await websocket.recv() | |
print(f"<<< {greeting}") | |
if __name__ == "__main__": | |
asyncio.run(hello()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment