Finally, we start the server on line (14). This time, we are using the Flask-SocketIO instance, socketio, rather than the core Flask app instance, as we did for the RESTful API server:
if __name__ == '__main__':
socketio.run(app, host="0.0.0.0", debug=True) # (14)
Well done! That's our Web Socket server complete.
We have now seen how we can build a Web Socket server using Python together with Flask-SocketIO. While the overall outcome of our Web Socket server implementation controls our LED similarly to our RESTful API server, what we have learned is a different approach to achieving the same end result. However, in addition to this, we demonstrated a feature provided by a Web Socket approach, which is how we can keep multiple web pages in sync!
You will find links in the Further reading section to the Flask-SocketIO documentation so you can further your knowledge even more.
Now that we have seen the Python server implementation of...