Flask pass unknown Url Arguments in url_for and redirects

I am curious if anyone came up with a good solution for passing unknown URL arguments in a jar. I think there should be a simple solution that I just completely close. Any help is appreciated.

Let's say i have www.example.com?foo=baz&bar=buzz

@app.route('/')
def index():
    foo = request.args.get('foo',None)
    bar = request.args.get('bar',None)
    return redirect(url_for('args', foo=foo, bar=bar, _external=True))

What I cannot understand is a good way to convey any unknown arguments. If I have www.example.com?foo=baz&bar=buzz&bing=bangor www.example.com?this=thatare going along the same path, I need to get any/andall the arguments in order to move on to the next view.

+4
source share
1 answer

request.args is a MultiDict .

MultiDict , , , , . , HTML .

MultiDict . , .

, , , *:

url_for('test', _external=True, **request.args)
+3

All Articles