Ai
1 Star 3 Fork 1

LMingJian/ExampleScript

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
025Socket通信io-service.py 636 Bytes
一键复制 编辑 原始数据 按行查看 历史
LMingJian 提交于 2022-07-04 16:11 +08:00 . M3U8 download
import eventlet
import socketio
from eventlet import wsgi
sio = socketio.Server()
@sio.event
def connect(sid, environ):
if environ:
print('connect ', sid)
@sio.event
def disconnect(sid):
print('disconnect ', sid)
@sio.event
def message(sid, data):
print('message received with ', data, sid)
sio.send({'response': 'OK'})
def message_handler(sid, msg):
print('Received message: ', msg, sid)
sio.send('OK')
sio.on('user', message_handler)
app = socketio.WSGIApp(sio, static_files={
'/': {'content_type': 'text/html', 'filename': 'index.html'}
})
wsgi.server(eventlet.listen(('', 5000)), app)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/LMingJian/example-script.git
git@gitee.com:LMingJian/example-script.git
LMingJian
example-script
ExampleScript
master

搜索帮助