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?

0

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.