python很方便的一个websocket库,不过不支持WSS,只支持WS
安装方法:
pip install git+https://github.com/Pithikos/python-websocket-server
pip install websocket-server
可以直接拷贝
websocket-server.py到你项目对应运行目录运行服务器:python server.py
例子:
import logging
from websocket_server import WebsocketServer
def new_client(client, server):
server.send_message_to_all("Hey all, a new client has joined us")
server = WebsocketServer(13254, host='127.0.0.1', loglevel=logging.INFO)
server.set_fn_new_client(new_client)
server.run_forever()
https://github.com/Pithikos/python-websocket-server
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。