summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/third_party/websockets/example/quickstart/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/tools/third_party/websockets/example/quickstart/client.py')
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/example/quickstart/client.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/third_party/websockets/example/quickstart/client.py b/testing/web-platform/tests/tools/third_party/websockets/example/quickstart/client.py
new file mode 100644
index 0000000000..8d588c2b0e
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/example/quickstart/client.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+import asyncio
+import websockets
+
+async def hello():
+ uri = "ws://localhost:8765"
+ 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())