Skip to content

Instantly share code, notes, and snippets.

@anandology
Created June 20, 2015 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anandology/16189f58c7486885fe45 to your computer and use it in GitHub Desktop.
Save anandology/16189f58c7486885fe45 to your computer and use it in GitHub Desktop.
Example to try incremental template rendering
<html>
<head><title>Incremental Tornado Templates</title></head>
<body>
<h1>Incremental Tornado Templates</h1>
{% import time %}
<ul>
{% for i in range(n) %}
<li>{{ i }}</li>
{{ time.sleep(delay) or "" }}
{% end %}
</ul>
</body>
</html>
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.render_async("index.html", n=100, delay=0.1)
if __name__ == "__main__":
application = tornado.web.Application([
(r"/", MainHandler),
])
application.listen(9999)
tornado.ioloop.IOLoop.current().start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment