From b558787d8146894709c42340f85c5bea4418e081 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Tue, 15 Jun 2021 20:25:49 +0000 Subject: fix crash when logging in or out on search results page --- apioforum/__init__.py | 10 +++++++++- apioforum/templates/base.html | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apioforum/__init__.py b/apioforum/__init__.py index 7baa7c1..c4348a3 100644 --- a/apioforum/__init__.py +++ b/apioforum/__init__.py @@ -1,7 +1,7 @@ # boilerplate boilerplate boilerplate # yay -from flask import Flask +from flask import Flask, request from .db import get_db import os @@ -32,6 +32,14 @@ def create_app(): from .fuzzy import fuzzy app.jinja_env.filters['fuzzy']=fuzzy + @app.context_processor + def path_for_next(): + p = request.path + if len(request.query_string) > 0: + p += "?" + request.query_string.decode("utf-8") + return dict(path_for_next=p) + + app.add_url_rule("/",endpoint="index") return app diff --git a/apioforum/templates/base.html b/apioforum/templates/base.html index ba96c91..87b142f 100644 --- a/apioforum/templates/base.html +++ b/apioforum/templates/base.html @@ -21,18 +21,18 @@ {% if g.user %}

{{ g.user }}

- + logout

{% else %}

- + login

- + register

-- cgit v1.2.3