我在定义自己的错误自定义消息时遇到问题。我不确定我是否正确执行此操作,但我正在尝试遵循文档:
http://flask-restful.readthedocs.org/en/latest/extending.html#define-custom-error-messages
这就是我的代码的样子:
from flask import Flask
from flask.ext import restful
myerrors = {
'CannotFind':{
'message':'We could not find it!',
'status':404
}
}
app = Flask(__name__)
api = restful.Api(app, errors = myerrors)
但是,当我运行此程序时,出现错误:
TypeError: __init__() got an unexpected keyword argument 'errors'
文档说Once your errors dictionary is defined, simply pass it to the Api constructor
那是我没有做的吗?
我还在他们使用的文档中注意到:
api = flask_restful.Api(app, errors=errors)
所以我以为我使用了不正确的东西,因此我尝试导入该 flask_restful 但它不存在...
所以现在我很困惑,请帮助!