【发布时间】:2018-05-25 08:24:40
【问题描述】:
使用 Tornado,我想创建一个 html 文件并将其保存以供以后重复使用。在 html 中,我想在我的静态文件中引用引导 css。
我的简化 html 看起来像这样,跟在 Tornado/Python self.render("example.html") ignores CSS 之后
<html>
<head>
<link rel="stylesheet" type="text/css" href="{{static_url('app/content/bootstrap.css')}}" />
</head>
<body>
{{name}}
</body>
</html>
我的简化 .py 看起来像这样:
import tornado.template
loader=tornado.template.Loader(r"C:\templateDirectory")
output_from_parsed_template= loader.load("template.html").generate(name="John")
# to save the results
file = open(r"C:\templateDirectory\result.html","w")
file.write(output_from_parsed_template)
file.close()
但是,我得到消息:
NameError: name 'static_url' is not defined
【问题讨论】:
标签: python html css twitter-bootstrap tornado