diff options
Diffstat (limited to 'testing/web-platform/tests/tools/third_party/websockets/example/faq/health_check_server.py')
-rw-r--r-- | testing/web-platform/tests/tools/third_party/websockets/example/faq/health_check_server.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/third_party/websockets/example/faq/health_check_server.py b/testing/web-platform/tests/tools/third_party/websockets/example/faq/health_check_server.py new file mode 100644 index 0000000000..7b8bded772 --- /dev/null +++ b/testing/web-platform/tests/tools/third_party/websockets/example/faq/health_check_server.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +import asyncio +import http +import websockets + +async def health_check(path, request_headers): + if path == "/healthz": + return http.HTTPStatus.OK, [], b"OK\n" + +async def echo(websocket): + async for message in websocket: + await websocket.send(message) + +async def main(): + async with websockets.serve( + echo, "localhost", 8765, + process_request=health_check, + ): + await asyncio.Future() # run forever + +asyncio.run(main()) |