我不是Cheetah或Flask专家,但我认为您不需要任何特殊支持才能使其发挥作用.看看两者的例子,我想出了这个(它似乎对我来说很好).
from flask import Flask
from Cheetah.Template import Template
mainTemplate = """
<html>
<head><title>$title</title></head>
<body><h1>$title</h1></body>
</html>"""
app = Flask(__name__)
@app.route('/')
def main_route():
return render(mainTemplate, {'title': 'Welcome to "/"!'})
def render(template, context):
"""Helper function to make template rendering less painful."""
return str(Template(template, namespaces=[context]))
if __name__ == "__main__":
app.run()
Run Code Online (Sandbox Code Playgroud)