summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py')
-rw-r--r--testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py b/testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py
new file mode 100644
index 0000000000..92f895d926
--- /dev/null
+++ b/testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py
@@ -0,0 +1,29 @@
+import logging
+
+import asyncio
+import websockets
+
+
+logging.basicConfig(level=logging.WARNING)
+
+# Uncomment this line to make only websockets more verbose.
+# logging.getLogger('websockets').setLevel(logging.DEBUG)
+
+
+HOST, PORT = "127.0.0.1", 8642
+
+
+async def echo(ws):
+ async for msg in ws:
+ await ws.send(msg)
+
+
+async def main():
+ with websockets.serve(echo, HOST, PORT, max_size=2 ** 25, max_queue=1):
+ try:
+ await asyncio.Future()
+ except KeyboardInterrupt:
+ pass
+
+
+asyncio.run(main())