python's docs

1.0.0 在template中获取url值


1. 使用request.path

# url:"http://domain.com/linux"  
\{\{ request.path \}\}
"/linux"

2. 使用request.url_rule.endpoint

# url:"http://domain.com/linux"  
\{\{ request.url_rule.endpoint \}\}
"linux"

3. 使用request.url

# url:"http://domain.com/linux"  
\{\{ request.url_rule.endpoint \}\}
"http://domain.com/linux"

4. 扩展:

stackoverflow ask doc
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:


PS

上面的\{\{\}\}是为了不和jinja2语法冲突,其实\只是转义符,实际使用时没有这个符号