1
竜巻を使用して、私はhtmlファイルを作成し、後で再利用するために保存します。 htmlの中に私の静的なファイルのブートストラップのCSSへの参照が欲しい。静的CSSへのリンク付きの竜巻付き.htmlファイルを作成
マイsimplfied 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
Ben Darnellに感謝します。 Tornadoでstatic_urlのテンプレートがどのように行われているかの例を教えてください。 – Joris
'tornado/web.py'の' static_url'を検索します。 –