From 1a7983052f172a5a5d19868ffe42d22e82c1be27 Mon Sep 17 00:00:00 2001 From: viveksantayana Date: Wed, 15 Jun 2022 11:33:09 +0100 Subject: [PATCH] Finished common views --- ref-test/app/views.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ref-test/app/views.py b/ref-test/app/views.py index ef48434..b77274e 100644 --- a/ref-test/app/views.py +++ b/ref-test/app/views.py @@ -1,4 +1,8 @@ -from flask import Blueprint, render_template +from ..config import Config + +from flask import Blueprint, redirect, request, render_template + +from datetime import datetime, timedelta views = Blueprint( name='common', @@ -9,4 +13,18 @@ views = Blueprint( @views.route('/privacy/') def _privacy(): - return render_template('privacy.html') \ No newline at end of file + return render_template('privacy.html') + +@views.route('/cookie_consent/') +def _cookie_consent(): + resp = redirect('/') + resp.set_cookie( + key='cookie_consent', + value='true', + max_age = timedelta(days=14) if request.cookies.get('remember') == 'True' else None, + path = '/', + expires = datetime.utcnow() + timedelta(days=14) if request.cookies.get('remember') else None, + domain = f'.{Config.SERVER_NAME}', + secure = True + ) + return resp \ No newline at end of file