【问题标题】:static_url calling in Tornado在 Tornado 中调用 static_url
【发布时间】:2013-03-01 14:36:39
【问题描述】:

我是 Python 和 Tornado 网络框架的初学者。当我在研究《Introduction to Tornado》一书中的模板部分时,有一句话让我很困惑:

<link rel="stylesheet" href="{{ static_url("style.css") }}">

当没有库导入命名空间时,应用程序如何知道在哪里调用函数static_url?我在 Tornado 的 web 模块中找到了static_url(),但是我不知道如何在那个模板文件中成功调用这个函数?

【问题讨论】:

    标签: python url static tornado


    【解决方案1】:

    RequestHandler 类有一个方法 get_template_namespace(),记录在 here。如果单击源链接,您将看到 how it creates a dictionary 其中 'static_url' 设置为 self.static_url

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-14
      • 1970-01-01
      • 2020-10-16
      • 2015-06-16
      • 1970-01-01
      相关资源
      最近更新 更多