Sometimes, we want to get the different parts of a Python Flask request’s URL.
In this article, we’ll look at how to get the different parts of a Python Flask request’s URL.
How to get the different parts of a Python Flask request’s URL?
To get the different parts of a Python Flask request’s URL, we can use various properties of request
.
For instance, if we have
http://www.example.com/myapplication
as the root URL and we make a request to
http://www.example.com/myapplication/foo/page.html?x=y
Then we can get all parts of http://www.example.com/myapplication/foo/page.html?x=y
by using the following properties
path
– /foo/page.htmlfull_path
– /foo/page.html?x=yscript_root
– myapplicationbase_url
– http://www.example.com/myapplication/foo/page.htmlurl
– http://www.example.com/myapplication/foo/page.html?x=yurl_root
– http://www.example.com/myapplication/
Conclusion
To get the different parts of a Python Flask request’s URL, we can use various properties of request
.