中止(400)引发500内部服务器错误 - Flask 1.0

时间:2018-04-30 03:44:16

标签: python exception flask werkzeug debug-mode

我有这个功能:

if not (payload.get('password') == payload.get('password_cpy')):
        abort(400)

当我运行带有烧瓶运行的应用程序并且调试关闭时,我得到一个BadRequest错误的相当印刷品,在raw中显示以下信息:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not 
understand.</p>

在终端上我看到了:

127.0.0.1 - - [30/Apr/2018 00:28:20] "POST /sign_in HTTP/1.1" 400 - 

当我运行它并打开调试时,我得到的错误是:

 werkzeug.exceptions.BadRequest
    werkzeug.exceptions.BadRequest: 400 Bad Request: The browser (or proxy) 
    sent a request that this server could not understand.

在终端我看到500错误:

127.0.0.1 - - [30/Apr/2018 00:29:27] "POST /sign_in HTTP/1.1" 500 -

为什么我会得到两种不同的行为?有没有办法即使在调试模式下我也能得到400错误?

1 个答案:

答案 0 :(得分:1)

尝试将Flask1.0更新为Flask1.0.1
我猜这个bug已在Flask1.0.1 :)中修复了

https://github.com/pallets/flask/issues/2735