Permalink
Browse files

Add error handler for 400 and 500

  • Loading branch information...
greyli committed Dec 30, 2018
1 parent f7f7355 commit 64751b52ededb916a1dc9f4f9879c4759861a6d8
Showing with 34 additions and 0 deletions.
  1. +10 −0 app.py
  2. +12 −0 templates/400.html
  3. +12 −0 templates/500.html
10 app.py
@@ -78,11 +78,21 @@ def inject_user():
return dict(user=user)


@app.errorhandler(400)
def bad_request(e):
return render_template('400.html'), 400


@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404


@app.errorhandler(500)
def internal_server_error(e):
return render_template('500.html'), 500


@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
@@ -0,0 +1,12 @@
{% extends 'base.html' %}

{% block content %}
<ul class="movie-list">
<li>
Bad Request - 400
<span class="float-right">
<a href="{{ url_for('index') }}">Go Back</a>
</span>
</li>
</ul>
{% endblock %}
@@ -0,0 +1,12 @@
{% extends 'base.html' %}

{% block content %}
<ul class="movie-list">
<li>
Internal Server Error - 500
<span class="float-right">
<a href="{{ url_for('index') }}">Go Back</a>
</span>
</li>
</ul>
{% endblock %}

0 comments on commit 64751b5

Please sign in to comment.