1

我添加了一个自定义身份验证类,return如果预定义的控件失败。
如果失败,客户端会收到这个答案:{"_error": {"code": 401, "message": "Please provide proper credentials"}, "_status": "ERR"}
我想知道是否可以自定义上述答案。
非常感谢

4

1 回答 1

2

您可以使用烧瓶的errorhandler装饰器来拦截 401,如下所示:

@app.errorhandler(401)
def my_own_error_msg(err):
    return make_response("Hello, this is Devo.", 401)

有关详细信息,make_response请参阅自定义错误处理程序

于 2014-10-30T06:33:40.203 回答