rewrite with flask-socketio