urlpython-3.xflaskwerkzeug

Whether urlencode is needed when dealing with Flask REST API?


I have a Flask based web application running, I am not sure whether the following two urls are equivalent with respect to a Flask request

www.example.com/hello?a=Hello+G%C3%BCnter

and

www.example.com/hello?a=Hello Günter

How are these urls translated into a Flask Request internally ?


Solution

  • The browser (or any other http client, like curl) should translate both of these urls into www.example.com/hello?a=Hello+G%C3%BCnter before sending to server, because www.example.com/hello?a=Hello Günter is not a valid HTTP URL. So Flask will receive www.example.com/hello?a=Hello+G%C3%BCnter in both cases, and supply it to view function arguments decoded, as "Hello Günter".