@bp.route('/<path:remaining>')
def socketio(remaining):
    app = current_app._get_current_object()
try:
    socketio_manage(request.environ, {'': ChatNamespace}, app)
except:
    app.logger.error('Exception while handling socket.io connection',
        exc_info=True)
return Response()


class ChatNamespace(BaseNamespace, RoomsMixin, BroadcastMixin):

    def __init__(self, environ, ns_name, request=None):
        self.context = None
if request:
    app = request
self.context = app.request_context(environ)
self.context.push()
app.preprocess_request()
super(ChatNamespace, self).__init__(environ, ns_name)

def log(self, message):
    self.context.app.logger.info('[{0}] {1}'.format(self.socket.sessid,
        message))

def disconnect(self, *args, **kwargs):
    if self.context:
        self.context.pop()
super(ChatNamespace, self).disconnect(*args, **kwargs)
Flask: невозможно получить доступ к current_app из прослушивателя socket.io