gpt4 book ai didi

python - 如何使用 jinja 模板获取 Google App Engine python 中的当前 url

转载 作者:太空宇宙 更新时间:2023-11-03 13:17:03 25 4
gpt4 key购买 nike

我正在使用 Google App Engine for Python 和 Jinja2 模板。有没有模板标签获取当前页面的URL。或者我是否必须将 url 作为变量从 View 代码传递给模板?

最佳答案

{{ request.url }} 给出了当前的 url。您需要完整的 url,还是只需要相对于根目录的路径?

例如,使用Flask,你可以拥有

{{ request.url }}
{{ request.base_url }}
{{ request.url_root }}
{{ request.host_url }}
{{ request.path }}

等等

关于python - 如何使用 jinja 模板获取 Google App Engine python 中的当前 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25986338/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com