add a python echo server that does not close the connection after each received messages
This commit is contained in:
@ -8,9 +8,10 @@ import websockets
|
||||
|
||||
|
||||
async def echo(websocket, path):
|
||||
msg = await websocket.recv()
|
||||
print(f'Received {len(msg)} bytes')
|
||||
await websocket.send(msg)
|
||||
while True:
|
||||
msg = await websocket.recv()
|
||||
print(f'Received {len(msg)} bytes')
|
||||
await websocket.send(msg)
|
||||
|
||||
host = os.getenv('BIND_HOST', 'localhost')
|
||||
print(f'Serving on {host}:8766')
|
||||
|
Reference in New Issue
Block a user