Flask abort() 或返回状态的区别 [英] Difference between Flask abort() or returning a status
本文介绍了Flask abort() 或返回状态的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
abort(400)
和返回状态为 400 的响应有什么区别?使用错误返回错误形式吗?
What is the difference between abort(400)
and returning a response with a 400 status? Is using return bad form for errors?
abort(400, "some error message")
# or
return {'message': "some error message"}, 400
推荐答案
abort
引发错误,错误处理程序会将其转换为响应.return
返回响应,错误处理程序不会触发.这取决于您希望您的应用程序如何流动.
abort
raises an error, which an error handler will convert to a response. return
returns a response, error handlers don't trigger. It's up to how you want your application to flow.
这篇关于Flask abort() 或返回状态的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文