前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python websocket服务器

Python websocket服务器

原创
作者头像
audy
修改2019-03-22 16:29:23
5.2K0
修改2019-03-22 16:29:23
举报

python很方便的一个websocket库,不过不支持WSS,只支持WS

安装方法:

  1. pip install git+https://github.com/Pithikos/python-websocket-server
  2. pip install websocket-server
  3. 可以直接拷贝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 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档