【发布时间】:2015-09-24 09:46:22
【问题描述】:
我目前正在构建一个使用 websockets 的烧瓶应用程序。为此,我想使用 flask-socketio 库。我已将客户端示例复制为per the docs instructions:
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script>
<script type="text/javascript" charset="utf-8">
var socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('connect', function() {
socket.emit('hello', {data: 'Hello there!'});
});
</script>
和一个简单的服务器端处理程序:
@socketio.on('hello')
def handle_hello(message):
print message
但是我在 borwserwindow 控制台中收到以下错误:
Uncaught TypeError: Cannot read the property 'onClose' of null.
有人知道我在这里做错了什么吗?
【问题讨论】:
标签: python-2.7 flask websocket