Created
June 20, 2015 22:54
-
-
Save anandology/16189f58c7486885fe45 to your computer and use it in GitHub Desktop.
Example to try incremental template rendering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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