feat: Enhance error handling responses with correct status codes

Updated error handlers for 404, 400, 429, and 500 HTTP error responses to explicitly return the corresponding status codes along with the error templates. This change ensures that responses not only serve the correct error pages but also reflect the appropriate HTTP status codes, improving compliance with HTTP standards and enhancing the clarity of the server's response to clients.

This adjustment aids in proper error diagnostics and handling by both the client applications and search engines, potentially influencing SEO and user experience positively by ensuring that web crawlers correctly interpret the nature of the errors.

Resolves issues related to ambiguous HTTP status codes in error responses.
This commit is contained in:
Kumi 2024-05-25 15:04:26 +02:00
parent db9f4d9207
commit c593904a19
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -1195,22 +1195,22 @@ def privacypolicy():
@app.errorhandler(404)
def not_found(e):
return render_template("404.html")
return render_template("404.html"), 404
@app.errorhandler(400)
def bad_request(e):
return render_template("400.html")
return render_template("400.html"), 400
@app.errorhandler(429)
def too_many_requests(e):
return render_template("429.html")
return render_template("429.html"), 429
@app.errorhandler(500)
def internal_server_error(e):
return render_template("500.html")
return render_template("500.html"), 500
def main():