Created
August 2, 2012 13:22
-
-
Save cjgiridhar/3237076 to your computer and use it in GitHub Desktop.
Tornado - Template - Extends
This file contains 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
{%extends "templateinheritance.html" %} | |
{% block header %} | |
<table border="1"> | |
<tr> | |
<td>Article2</td> | |
<td>Author2</td> | |
</tr> | |
{% end %} |
This file contains 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>Articles</title> | |
</head> | |
<body> | |
<h4>Articles available</h4> | |
<table border="1"> | |
<tr> | |
<td>Article1</td> | |
<td>Author1</td> | |
</tr> | |
<tr> | |
<td>Article2</td> | |
<td>Author2</td> | |
</tr> | |
<tr> | |
<td>Article3</td> | |
<td>Author3</td> | |
</tr> | |
</table> | |
<h4> {{ username }}, you've read these articles</h4> | |
{% block header %} | |
<table border="1"> | |
<tr> | |
<td>None</td> | |
<td>None</td> | |
</tr> | |
{% end %} | |
</body> | |
</html> |
This file contains 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 | |
import time | |
class ItWorks(tornado.web.RequestHandler): | |
def get(self): | |
self.write("It Works!!") | |
class Article(tornado.web.RequestHandler): | |
def get(self): | |
self.render('custom.html', username='John') | |
## title and dict is handled by template.html | |
application = tornado.web.Application([ | |
(r"/", ItWorks), | |
(r"/articles", Article), | |
],debug=True) | |
if __name__ == "__main__": | |
application.listen(8888) | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment