擅长:python、mysql、java
<p>根据这两个教程,它看起来非常简单:</p>
<pre>
import stringtemplate
import cherrypy
class HelloWorld(object):
def index(self):
hello = stringtemplate.StringTemplate("Hello, $name$")
hello["name"] = "World"
return str(hello)
index.exposed = True
cherrypy.quickstart(HelloWorld())
</pre>
<p>您可能想让CherryPy函数在磁盘上的某个位置找到StringTemplate,但总体思路是这样的。在</p>
<p>Django在概念上类似:url被映射到python函数,python函数通常构建一个上下文字典,用该上下文对象呈现模板,并返回结果。在</p>