Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Tornado - Templates
<title>{{ title }}</title>
<table border="1">
{% for key,value in dict.items() %}
<td>{{ key }}</td>
<td>{{ value }}</td>
{% end %}
import tornado.ioloop
import tornado.web
import time
class ItWorks(tornado.web.RequestHandler):
def get(self):
self.write("It Works!!")
class Article(tornado.web.RequestHandler):
def get(self):
articles = {"tornado":"Python",
self.render('template.html', title='Articles', dict=articles)
## title and dict is handled by template.html
application = tornado.web.Application([
(r"/", ItWorks),
(r"/articles", Article),
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment