Files
Python-2020/server_websocket.py
2021-01-13 00:42:36 +01:00

13 lines
296 B
Python
Executable File

#!/usr/bin/env python
import asyncio
import websockets
async def echo(websocket, path):
async for message in websocket:
await websocket.send(message)
asyncio.get_event_loop().run_until_complete(
websockets.serve(echo, 'localhost', 8765))
asyncio.get_event_loop().run_forever()