在flask restful的资源文件中发送事件-flask-socketIO

时间:2020-06-08 09:14:10

标签: python flask socket.io flask-restful

让我们说资源看起来像这样:

class MessageSender(Resource):       
    @jwt_required
    def post(self, conversation_id):      
        emit('newMessage', conversation_id, broadcast=True)
        return {'message': "Messaged has been sent"},201

它将返回AttributeError:'Request'对象没有属性'namespace'

在主文件中:

api = Api(app)
socketio = SocketIO(app,cors_allowed_origins='*')

如何从资源文件中的同一socketIO对象发出事件? 谢谢

0 个答案:

没有答案