【发布时间】:2014-03-05 12:35:10
【问题描述】:
通过abort()方法很容易将flask-restful的错误信息传播给客户端,比如
abort(500, message="Fatal error: Pizza the Hutt was found dead earlier today
in the back seat of his stretched limo. Evidently, the notorious gangster
became locked in his car and ate himself to death.")
这将生成以下 json 输出
{
"message": "Fatal error: Pizza the Hutt was found dead earlier today
in the back seat of his stretched limo. Evidently, the notorious gangster
became locked in his car and ate himself to death.",
"status": 500
}
有没有办法用其他成员自定义 json 输出?例如:
{
"sub_code": 42,
"action": "redirect:#/Outer/Space"
"message": "You idiots! These are not them! You've captured their stunt doubles!",
"status": 500
}
【问题讨论】:
标签: flask werkzeug flask-restful