From fba919de8cc70dc8ec28e1416bb31b36acd79e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana?= Date: Mon, 5 Jun 2023 00:52:14 +0200 Subject: [PATCH] Login required --- benchmark/scripts/flask_app/app.db | Bin 0 -> 16384 bytes benchmark/scripts/flask_app/app.py | 13 ++++-- benchmark/scripts/flask_app/config.py | 5 ++ benchmark/scripts/flask_app/forms.py | 22 +++++++++ benchmark/scripts/flask_app/main.py | 44 ++++++++++++++++-- benchmark/scripts/flask_app/models.py | 17 ++++++- .../scripts/flask_app/templates/base.html | 17 +++++-- .../scripts/flask_app/templates/login.html | 6 +++ .../scripts/flask_app/templates/results.html | 5 ++ 9 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 benchmark/scripts/flask_app/app.db create mode 100644 benchmark/scripts/flask_app/forms.py create mode 100644 benchmark/scripts/flask_app/templates/login.html create mode 100644 benchmark/scripts/flask_app/templates/results.html diff --git a/benchmark/scripts/flask_app/app.db b/benchmark/scripts/flask_app/app.db new file mode 100644 index 0000000000000000000000000000000000000000..b705552d4bda8c923fd89a6faf47849ce3103908 GIT binary patch literal 16384 zcmeI&L2uJA6bEpp8QmIbluOkkt~7~8f+=ZIYu#zxh@c{*TWA@*P`PzNBbIhb3QXcu zz7yYR;>ah!2@CBm69-P??Oe)wZoCa4d;lj{5G1KFWL00Izz00bZa0SG_<0uX=z1pZFIQ_J-y zHDwXaMQ{~ejX$M9G7e%MU1X!J6W{3$96I!RXG4efyywn4dMk_eJ(^|GX8tGryi~3~ zt0`Y^)yop*JPxv6y{lxAxUO16^wnc!yI!j)-x^CkxyVapbETVdgYL2G+^j^aL_)50 z;Jk2r>h%ZI8@ldOs#S_&^ljHadD-=w%+|AbzVtsqvt{JbOP;1*7Ks?ocskpdJ;-NI z{od=YKccUk5p707*Yxacu2fSZFEj{100Izz00bZa0SG_<0uX=z1pb}CN>j?D(O!*` zcrjn{x%{n1M<24+82i&jd^!0j!q#CrZPa-cg2tWV= z5P$##AOHafKmY;|fB*#UjlizjsI1>N{67C*lj=25".format(self.username) + return "".format(self.username, self.email) + + def set_password(self, password): + self.password_hash = generate_password_hash(password) + + def check_password(self, password): + return check_password_hash(self.password_hash, password) + + def avatar(self, size): + digest = md5(self.email.lower().encode("utf-8")).hexdigest() + return "https://www.gravatar.com/avatar/{}?d=identicon&s={}".format( + digest, size + ) diff --git a/benchmark/scripts/flask_app/templates/base.html b/benchmark/scripts/flask_app/templates/base.html index 5ec9ff3..af81b88 100644 --- a/benchmark/scripts/flask_app/templates/base.html +++ b/benchmark/scripts/flask_app/templates/base.html @@ -5,13 +5,20 @@ - {% block styles %} - - {{ bootstrap.load_css() }} - {% endblock %} + {% block styles %}{{ bootstrap.load_css() }}{% endblock %} Benchmark {% endblock %} - {% include "_nav.html" %} + + {% include "_nav.html" %} + {% with messages = get_flashed_messages() %} + {% if messages %} + {% for message in messages %}{% endfor %} + {% endif %} + {% endwith %} +
+ {% block content %}{% endblock %} +
+ {% block jscript %}{{ bootstrap.load_js() }}{% endblock %} diff --git a/benchmark/scripts/flask_app/templates/login.html b/benchmark/scripts/flask_app/templates/login.html new file mode 100644 index 0000000..00b45f3 --- /dev/null +++ b/benchmark/scripts/flask_app/templates/login.html @@ -0,0 +1,6 @@ +{% extends 'base.html' %} +{% from 'bootstrap5/form.html' import render_form %} +{% block content %} +

Login

+ {{ render_form(form) }} +{% endblock content %} diff --git a/benchmark/scripts/flask_app/templates/results.html b/benchmark/scripts/flask_app/templates/results.html new file mode 100644 index 0000000..2be1d76 --- /dev/null +++ b/benchmark/scripts/flask_app/templates/results.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} +{% block content %} +

Home

+

Welcome to the home page!

+{% endblock content %}