0

I am trying to work with querys in Flask. I have a page choose.html where you can click buttons. these should be sent in a query then to page 2. So page 2 should be rendered by Flask with the query e.g.

127.0.0.1/login?username=test&color=3

I have tried the following so far (hard coded):

<a href="{{ url_for('login?username=test&color=3') }}"><button class="continue" id="submit" name="submit">Continue</button></a>
@app.route('/login', methods=['post', 'get'])
def login():
    message = request.args.get('username')

That was the response: werkzeug.routing.BuildError: Could not build url for endpoint 'login?username=test'. Did you mean 'login' instead?

davidism
  • 121,510
  • 29
  • 395
  • 339
Flouu
  • 45
  • 4

1 Answers1

0

Found out the answer:

{{ url_for('login', user='foo', name='test') }}

This will create a query like this:

http://127.0.0.1:10000/login?user=foo&name=test
Flouu
  • 45
  • 4