How do I get the different parts of a Flask request's url?

I want to detect if the request came from the localhost:5000 or foo.herokuapp.com host and what path was requested. How do I get this information about a Flask request?

You can examine the url through several Request fields:

A user requests the following URL:

>         http://www.example.com/myapplication/page.html?x=y
>

In this case the values of the above mentioned attributes would be the following:

>         path             /page.html
>         script_root      /myapplication
>         base_url         http://www.example.com/myapplication/page.html
>         url              http://www.example.com/myapplication/page.html?x=y
>         url_root         http://www.example.com/myapplication/
>

You can easily extract the host part with the appropriate splits.

From: stackoverflow.com/q/15974730

Back to homepage or read more recommendations: