codekingpro/portable-devtools
115k
1#!/usr/bin/env python2 3# From https://github.com/aaugustin/websockets/blob/main/example/echo.py4 5import asyncio6import os7 8import websockets9 10LOCAL_WS_SERVER_PORT = int(os.environ.get("LOCAL_WS_SERVER_PORT", "8765"))11 12 13async def echo(websocket):14 async for message in websocket:15 await websocket.send(message)16 17 18async def main():19 async with websockets.serve(echo, "localhost", LOCAL_WS_SERVER_PORT):20 await asyncio.Future() # run forever21 22 23asyncio.run(main())24 