Small, realtimed applications are just beautiful. One can think of an idea, and implement it in no time, and still have a very lively app. I was searching for realtime possibilities which can couple up with Flask, and found a pretty decent solution, a Flask extension, Flask-socketIO.
In a nutshell, socketio is a nodejs realtime app framework, which allows realtimed bidirectional communication.
On to the code, we need the following pythonic requirements:
Flask-socketIO makes it very simple to implement event based communication.
Here is a sample server code:
Messages in server logs:
Another project of mine, “CodeCast“, has a more practical implementation of Flask-socketIO, which might provide a better understanding of the scenario.