Added error handlers
This commit is contained in:
Binary file not shown.
@@ -42,3 +42,13 @@ def short_url(token):
|
|||||||
else:
|
else:
|
||||||
# Redirect to the url of the token
|
# Redirect to the url of the token
|
||||||
return redirect(query.url)
|
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
@@ -11,8 +11,6 @@ body {
|
|||||||
|
|
||||||
.headers {
|
.headers {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
top: 3vh;
|
top: 3vh;
|
||||||
@@ -40,8 +38,6 @@ body {
|
|||||||
|
|
||||||
.container {
|
.container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
background-color: #2c2c2c;
|
background-color: #2c2c2c;
|
||||||
@@ -86,7 +82,7 @@ body {
|
|||||||
border-color: #7b59a5;
|
border-color: #7b59a5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error-message {
|
.url-error-message {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 100%;
|
font-size: 100%;
|
||||||
@@ -94,6 +90,15 @@ body {
|
|||||||
margin: 3% 0 0 0;
|
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 {
|
.page-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
|
|||||||
@@ -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 %}
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
</form>
|
</form>
|
||||||
{% if form.url.errors %}
|
{% if form.url.errors %}
|
||||||
{% for error in form.url.errors %}
|
{% for error in form.url.errors %}
|
||||||
<p class="error-message">{{ error }}</p>
|
<p class="url-error-message">{{ error }}</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user