Y
Y
yamudaqq2020-08-31 12:02:38
Flask
yamudaqq, 2020-08-31 12:02:38

Link structure in Flask and the question mark?

there is a code

@app.route('/auth/<path:code>')
def auth(code):
    return code


for example, the user follows the link /auth/?code=8df995db3ab52b9ea8. how can i extract "8df995db3ab52b9ea8" from here?

with a question mark doesn't work even with path. without a question mark is a trite split, but when there is a question mark, the flask does not even understand what exactly this code should be executed.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
soremix, 2020-08-31
@yamudaqq

It's called GET parameters.
request.args.get('code')

J
javedimka, 2020-08-31
@javedimka

Remove the question mark.
Solved problem.
PS without the question mark, your 8df995db3ab52b9ea8 is already in the code variable

C
cython, 2020-08-31
@cython

What prevents google "How to get the GET parameter flask?"

from flask import request
...
@app.route('/auth')
def auth():
    return request.args['code']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question