diff --git a/main.py b/main.py index dd00e68..36863d5 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -from flask import Flask, redirect, url_for, render_template, request, Response, send_from_directory, g +from flask import Flask, redirect, url_for, render_template, request, Response, send_from_directory, g, flash, get_flashed_messages from dotenv import load_dotenv from constants import RICKROLL_LINK, UPLOAD_DIR, MINIMUM_COSINE_SIMILARITY, DATABASE_FILE from jina import get_grass_touching_similarity @@ -86,7 +86,8 @@ def login(): return redirect(url_for("iamarealpersonwhotouchedgrass")) else: cur.close() - return Response("Unathorized access. Just go outside, touch grass and make your own account...") + flash("Unathorized access. Just go outside, touch grass and make your own account...", "error") + return render_template("unathorized.jinja2") @app.route("/register", methods=["GET", "POST"]) def register(): diff --git a/templates/unathorized.jinja2 b/templates/unathorized.jinja2 new file mode 100644 index 0000000..44e4c2d --- /dev/null +++ b/templates/unathorized.jinja2 @@ -0,0 +1,13 @@ +{% extends "base.jinja2" %} +{% block title %}Grass Touching Unathorized{% endblock %} + +{% block body %} +{% with messages = get_flashed_messages()%} +{% if messages%} + {% for message in messages%} +
{{message}}
+ {%endfor%} + {%endif%} + {%endwith%} + +{% endblock %} \ No newline at end of file