Catching a 500 server error in Flask

后端 未结 6 1585
-上瘾入骨i
-上瘾入骨i 2021-02-01 12:41

I love Flask\'s error catching. It\'s beautifully simple:

@app.errorhandler(404)
def pageNotFound(error):
    return \"page not found\"

works

6条回答
  •  忘掉有多难
    2021-02-01 13:24

    My solution to this was to turn on the propagation of exceptions, by modifying the config dictionary:

    app = Flask(__name__)
    ...
    app.config['PROPAGATE_EXCEPTIONS'] = True
    

    Look at this other related question: Flask app raises a 500 error with no exception

提交回复
热议问题