Skip to content

Is there a way to catch events without JavaScript in Flask?

My application handels a countdown, which refreshes all the time. The countdown itself is handeld by the server, like so:

def update_countdown():
   # do some stuff here to gather countdown
   socketio.emit("update-countdown", countdown)

Currently I am catching the event data in JavaScript like this:

var socket = io.connect();

var countdown_wrapper = document.getElementById("countdown");
socket.on("update-countdown", function(countdown) {
   countdown_wrapper.innerHTML = countdown;

Q.: Is there a way to catch events without JavaScript? If so, how could I do this?


If you are looking to replace javascript with python within your web browser’s client-side code, you might want to look into

It is essentially just using python within the browser. You wouldn’t have all of those fancy decorators, but it would probably work well enough.