import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello PyWeb")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
When used, request is done when finish is called.
URL = 'http://www.bankisrael.gov.il/currency.xml'
class CurrencyHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self):
http = httpclient.AsyncHTTPClient()
http.fetch(URL, self._got_currency)
def _got_currency(self, response):
self.write(response.body)
self.finish()
Compiled to python
No restrictions on expressions
{% for student in
[p for p in people if p.age > 23] %}
<li>{{ escape(student.name) }}</li>
{% end %}
Can pass custom functions like variables.
python
def add(x, y):
return x + y
template.execute(add=add)
template
{{ add(1, 2) }}
Mixins implementing various third-party authentication schemes
- OpenID
- OAuth, OAuth2
- FriendFeed