Bootstrap FreeKB - Jinja - Get URL endpoint with parameters
Jinja - Get URL endpoint with parameters

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 9b2e29 in the box below so that we can be sure you are a human.