Web sockets in Python (using flask) issue Web sockets in Python (using flask) issue flask flask

Web sockets in Python (using flask) issue


You are referencing the wrong element in your HTML/Javascript.

I'm guessing you want the value in this line to update, yes?

<h2><span id="user-count">0</span> visitors have seen this page! </h2>

Yet, your Javascript code calling out to the websocket is updating an element with ID connected:

socket.on('msg', function(msg) {    $("#connected").html(msg.count);  // <--- this line is updating the wrong thing!});

So, you can either update the SPAN tag ID to be connected, or you can update your socket message handler to call $('#user-count').html(msg.count);.