realpython / book2-exercises

Book 2 -- Exercises for the book
168 stars 203 forks source link

About 404 error handling in FlaskTaskr #34

Closed ni8mr closed 9 years ago

ni8mr commented 9 years ago

Hello, in the book, the 404 error handling process is defined like this-

@app.errorhandler(404)
def internal_error(error):
    return render_template('404.html'), 404

Is it necessary to write a 404 after render_template('404.html')? The function has worked without it-

@app.errorhandler(404)
def internal_error(error):
    return render_template('404.html')

It is at 281 page of the book.

mjhea0 commented 9 years ago

Hi - It will work without the 404 on the end, but you def. want to add it on since that defines the actual status code.

http://flask.pocoo.org/docs/0.10/quickstart/#about-responses

ni8mr commented 9 years ago

Thank you!