Added error handlers

This commit is contained in:
xemeds
2020-07-20 17:51:52 +00:00
parent c5f3f5a8c4
commit b6ed78c8ad
5 changed files with 35 additions and 7 deletions
BIN
View File
Binary file not shown.
+10
View File
@@ -42,3 +42,13 @@ def short_url(token):
else:
# Redirect to the url of the token
return redirect(query.url)
# Error handling routes
@app.errorhandler(404)
def error_404(error):
return render_template("error.html", error_message="404 Not Found"), 404
@app.errorhandler(500)
def error_500(error):
return render_template("error.html", error_message="500 Internal Server Error"), 500
+10 -5
View File
@@ -11,8 +11,6 @@ body {
.headers {
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
top: 3vh;
@@ -40,8 +38,6 @@ body {
.container {
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
background-color: #2c2c2c;
@@ -86,7 +82,7 @@ body {
border-color: #7b59a5;
}
.error-message {
.url-error-message {
color: #ffffff;
text-align: center;
font-size: 100%;
@@ -94,6 +90,15 @@ body {
margin: 3% 0 0 0;
}
.error-message {
position: absolute;
left: 0;
right: 0;
color: #ffffff;
text-align: center;
margin: 40vh auto 0 auto;
}
.page-container {
position: relative;
min-height: 100vh;
+13
View File
@@ -0,0 +1,13 @@
{% extends "layout.html" %}
{% block body %}
<body>
<div class="headers">
<a class="title" href="{{ url_for('index') }}">tiny0</a>
<h1 class="desc">Custom URL Shortener</h1>
</div>
<div class="error-message">
<h1>{{ error_message }}</h1>
</div>
</body>
{% endblock %}
+1 -1
View File
@@ -24,7 +24,7 @@
</form>
{% if form.url.errors %}
{% for error in form.url.errors %}
<p class="error-message">{{ error }}</p>
<p class="url-error-message">{{ error }}</p>
{% endfor %}
{% endif %}
</div>