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.html -
full_path
– /foo/page.html?x=y -
script_root
– myapplication -
base_url
– http://www.example.com/myapplication/foo/page.html -
url
– http://www.example.com/myapplication/foo/page.html?x=y -
url_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
.