Jinja - Get URL endpoint with parameters

by
Jeremy Canfield |
Updated: September 14 2023
| Jinja articles
If you are not familiar with Jinja, check out Getting Started with Jinja.
Let's say you have a URL like this.
http://www.example.com/foo?bar=hello
request can be used to return the URL. This is based on.
For example.
endpoint = {{ url_for(request.endpoint) }}
<br />
url_rule.endpoint = {{ url_for(request.url_rule.endpoint) }}
<br />
view_args = {{ url_for(request.endpoint, **request.view_args) }}
<br />
bar = {{ request.args.get('bar') }}
Which should return.
endpoint = /
url_rule.endpoint = /foo
view_args = /foo
bar = hello
Did you find this article helpful?
If so, consider buying me a coffee over at