embedded-framework/external/libhv/libhv-1.3.2/scripts/websocket_server.py
2024-03-08 07:16:14 -08:00

19 lines
377 B
Python
Executable File

#!/usr/bin/env python3
# pip3 install websockets
import asyncio
import websockets
async def echo(websocket):
async for message in websocket:
print(message)
await websocket.send(message)
async def serve(port):
async with websockets.serve(echo, "0.0.0.0", port):
await asyncio.Future()
if __name__ == "__main__":
asyncio.run(serve(9999))