diff options
author | rubenwardy <rw@rubenwardy.com> | 2020-07-12 17:15:30 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2020-07-12 17:15:30 +0100 |
commit | f437850a501cfee91dc70ad6d88d2ed215f8b2c6 (patch) | |
tree | e1041c2c1c0d9dfaf11427d8f5b21cf59c6c486a /app/utils.py | |
parent | 820c968f7354a8485d55921c7ecf585517b544e8 (diff) | |
download | cheatdb-f437850a501cfee91dc70ad6d88d2ed215f8b2c6.tar.xz |
Add global url_set_query Jinja template function
Diffstat (limited to 'app/utils.py')
-rw-r--r-- | app/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/utils.py b/app/utils.py index 5960fa6..cc338b4 100644 --- a/app/utils.py +++ b/app/utils.py @@ -23,6 +23,8 @@ from . import app import random, string, os, imghdr from urllib.parse import urljoin +# These are given to Jinja in template_filters.py + def abs_url_for(path, **kwargs): scheme = "https" if app.config["BASE_URL"][:5] == "https" else "http" return url_for(path, _external=True, _scheme=scheme, **kwargs) @@ -30,6 +32,11 @@ def abs_url_for(path, **kwargs): def abs_url(path): return urljoin(app.config["BASE_URL"], path) +def url_set_query(**kwargs): + args = dict(request.args) + args.update(kwargs) + return url_for(request.endpoint, **args) + def get_int_or_abort(v, default=None): if v is None: return default |