from flask import request
from werkzeug import url_encode

@app.template_global()
def modify_query(**new_values):
    args = request.args.copy()
for key, value in list(new_values.items()):
    args[key] = value
return '{}?{}'.format(request.path, url_encode(args))
Modify query parameters in current GET request for new url