Skip to content
Permalink
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (24 sloc) 792 Bytes
<script src="{{url_for('static', filename='js/socket.io-1.4.3.js')}}"></script>
<h1>Flask SQLAlchemy and SocketIO demo</h1>
<a href='/delete'>Delete all updates</a>
<h3>Updates</h3>
<ul id="update-list">
{% for update in updates %}
<li>{{update.msg}} at {{update.timestamp}}</li>
{% endfor %}
</ul>
<script>
var socket = io.connect('/browser');
document.onbeforeunload = function() {
console.log('Disconnecting from SocketIO ...');
socket.disconnect();
}
socket.on('connect', function() {
console.log('SocketIO connected.');
});
socket.on('new_update', function(data) {
var el = document.createElement('li');
el.innerHTML = data;
document.getElementById("update-list").appendChild(el);
});
</script>
You can’t perform that action at this time.