python - Flask not redirecting correctly? -


so input html code , redirect other function.

@app.route('/', methods = ['post']) def search():     rsn = request.form['username']     return redirect(url_for('username', rsn=rsn)) 

it redirects following function:

@app.route('/username=<rsn>', methods = ['get', 'post']) def username(rsn):     ... 

i expected url 1 app.route says... if rsn = hey url be

/username=hey 

but reason url turns into

/username%3dhey 

why?

= reserved character in urls, , flask correctly url percent encoding character %3d. reserved character because carries special meaning in path parameters , query strings.

your browser , flask still handle character correctly.

note flask not support routes path parameters (key-value pairs after path element, delimited ; colon), = valid delimiter character; instead use path elements parameters directly. if wanted write custom converter capture (;key(=value)?)* patterns.


Comments