📜  派 | websocket - 服务器 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:39.922000             🧑  作者: Mango

代码示例1
#!/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()