diff options
Diffstat (limited to 'testing/web-platform/tests/tools/third_party/websockets/example/deployment/render')
2 files changed, 37 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/third_party/websockets/example/deployment/render/app.py b/testing/web-platform/tests/tools/third_party/websockets/example/deployment/render/app.py new file mode 100644 index 0000000000..4ca34d23bb --- /dev/null +++ b/testing/web-platform/tests/tools/third_party/websockets/example/deployment/render/app.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import asyncio +import http +import signal + +import websockets + + +async def echo(websocket): + async for message in websocket: + await websocket.send(message) + + +async def health_check(path, request_headers): + if path == "/healthz": + return http.HTTPStatus.OK, [], b"OK\n" + + +async def main(): + # Set the stop condition when receiving SIGTERM. + loop = asyncio.get_running_loop() + stop = loop.create_future() + loop.add_signal_handler(signal.SIGTERM, stop.set_result, None) + + async with websockets.serve( + echo, + host="", + port=8080, + process_request=health_check, + ): + await stop + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/testing/web-platform/tests/tools/third_party/websockets/example/deployment/render/requirements.txt b/testing/web-platform/tests/tools/third_party/websockets/example/deployment/render/requirements.txt new file mode 100644 index 0000000000..14774b465e --- /dev/null +++ b/testing/web-platform/tests/tools/third_party/websockets/example/deployment/render/requirements.txt @@ -0,0 +1 @@ +websockets |