websocket for python

https://github.com/aaugustin/websocketsserver.py#!/usr/bin/env pythonimport asyncioimport websocketsasync def send(websocket, path):    while True:        if not websocket.open:            return        name = await websocket.recv()        await websocket.send("{}".format(name))        print("{}".format("{}".format(name)))start_server = websockets.serve(send, '192.168.2.150', 8765)asyncio.get_event_loop().run_until_complete(start_server)asyncio.get_event_loop().run_forever()
相關文章
相關標籤/搜索