Flask not redirecting correctly?
So, I am getting input from my html with this code and then redirecting it to another function.
@app.route('/', methods = ['POST'])
def search():
rsn = request.form['username']
return redirect(url_for('username', rsn=rsn))
It redirects to the following function:
@app.route('/username=<rsn>', methods = ['GET', 'POST'])
def username(rsn):
...
I expected the url to be what app.route says ... so if rsn = Hey the url will be
/username=Hey
But somehow the url turns into
/username%3DHey
Why?
source to share
=
is a reserved character in URLs , and the checkbox is URL-encoded correctly for the character %3D
. This is a reserved character because it has special meaning in path and query string parameters .
Your browser and checkbox will still process the character.
Note: the checkbox does not support routes with path parameters (key-value pairs after the path element, separated by a bottom ;
), where =
would be a valid delimiter character; instead, you usually use the path elements as parameters directly. If you really wanted you to burn a custom converter to burn templates (;key(=value)?)*
.
source to share