class IndexHandler(tornado.web.RequestHandler):
def get(self):
self.render('index.html')
if __name__ == '__main__':
tornado.options.parse_command_line()
app = tornado.web.Application(
handlers=[(r'/', IndexHandler), (r'/poem', PoemPageHandler)],
template_path=os.path.join(os.path.dirname(__file__), "templates")
)
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
>>> from tornado.template import Template
>>> content = Template("{{ header }}
")
>> print content.generate(header="Welcome!")
Welcome!</h1>></html>