summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/third_party/websockets/compliance/test_server.py
blob: 92f895d92695ead26d16bea27b0e4dbbc1fb022e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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())