Python 烧瓶在路径中发射

Python 烧瓶在路径中发射,python,flask,socket.io,flask-socketio,Python,Flask,Socket.io,Flask Socketio,我不能在途中发射。我想在调用函数时发出,但它给出了错误 像这样` @app.route('/') def index(): return render_template('index.html') @socketio.on('my event') @app.route('/hello', methods=['POST', 'GET']) def hello(): emit('my response', {'data': 'got it!'}) return "

我不能在途中发射。我想在调用函数时发出,但它给出了错误

像这样`

@app.route('/')
def index():
    return render_template('index.html')

@socketio.on('my event')
@app.route('/hello', methods=['POST', 'GET'])
def hello():
    emit('my response', {'data': 'got it!'})
    return "11"

在flask socketio中使用
命名空间
,以在路由中发射

@socketio.on('my event', namespace='/hello')
def hello():
    emit('my response', {'data': 'got it!'})
    return "11"

在flask socketio中使用
命名空间
,以在路由中发射

@socketio.on('my event', namespace='/hello')
def hello():
    emit('my response', {'data': 'got it!'})
    return "11"

如果在HTTP请求中发出,则需要指定
名称空间
房间
。这些是在您答复事件时从上下文中获得的,但在HTTP请求中这些是未知的,因此需要提供它们。如果您在HTTP请求中发出,则需要指定
名称空间
房间
。这些是在您回复事件时从上下文中获得的,但在HTTP请求中这些是未知的,因此需要提供它们。