From 0910c83e01d1a1e91a7e61d31ad813082612a268 Mon Sep 17 00:00:00 2001 From: xemeds Date: Fri, 7 Aug 2020 17:28:35 +0300 Subject: [PATCH] Changed the way error messages are displayed --- tiny0/routes.py | 6 +++--- tiny0/static/style.css | 2 +- tiny0/templates/error.html | 7 ++++--- tiny0/templates/index.html | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tiny0/routes.py b/tiny0/routes.py index 7e54400..700de53 100644 --- a/tiny0/routes.py +++ b/tiny0/routes.py @@ -37,7 +37,7 @@ def short_url(token): # If the query response was empty if not query: # Return the error page with a 404 not found error - return render_template("error.html", error_message="404 Not Found"), 404 + return render_template("error.html", error_code=404, error_message="Not Found"), 404 # Else if the query response contained data else: @@ -52,8 +52,8 @@ def donate(): # Error handling routes @app.errorhandler(404) def error_404(error): - return render_template("error.html", error_message="404 Not Found"), 404 + return render_template("error.html", error_code=404, error_message="Not Found"), 404 @app.errorhandler(500) def error_500(error): - return render_template("error.html", error_message="500 Internal Server Error"), 500 + return render_template("error.html", error_code=500, error_message="Internal Server Error"), 500 diff --git a/tiny0/static/style.css b/tiny0/static/style.css index 298c495..3de46b0 100644 --- a/tiny0/static/style.css +++ b/tiny0/static/style.css @@ -90,7 +90,7 @@ body { color: #ffffff; text-align: center; font-size: 100%; - margin: 1.5% 0 0 0; + margin: 2vh 0 0 0; } .error-message { diff --git a/tiny0/templates/error.html b/tiny0/templates/error.html index e38b922..dfce0d6 100644 --- a/tiny0/templates/error.html +++ b/tiny0/templates/error.html @@ -7,8 +7,9 @@

Custom URL Shortener

-
-

{{ error_message }}

-
+ {% endblock %} \ No newline at end of file diff --git a/tiny0/templates/index.html b/tiny0/templates/index.html index 0ead00b..eaa9d9b 100644 --- a/tiny0/templates/index.html +++ b/tiny0/templates/index.html @@ -19,7 +19,7 @@
{{ form.hidden_tag() }}
- {{ form.url(placeholder="Enter the URL here", class="url") }} + {{ form.url(placeholder="Enter the URL here", autofocus=true, class="url") }} {{ form.submit(class="button") }}
{% if form.url.errors %}