Your SlideShare is downloading. ×
Tornado my
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Tornado my

1,069

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,069
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Real Time Web Server
  • 2. • Real Time, so what? • Tornado – The baby that comes with it • 1000s simultaneously active connections
  • 3. • • • • • • Open-source (Apache 2.0 License) Nginx Non-blocking web server Epoll (callbacks on the kernel file structure) Push vs Pull (long polling) Real-time web services
  • 4. - Module List web escape •FriendFeed •core •XHTML •JSON •URL encoding/decoding database •MySQL template •Python-based templating language httpClient auth S3Server •Non-blocking http client •Works with web module •Google OpenID/OAuth, Yahoo BBAuth •Facebook Platform • Twitter OAuth •Amazon S3
  • 5. - Code Snippets • URL Mapping (get + post) class MainHandler(tornado.web.RequestHandler): def get(self): self.write("You requested the main page") class StoryHandler(tornado.web.RequestHandler): def get(self, story_id): self.write("You requested the story " + story_id) application = tornado.web.Application([ (r"/", MainHandler), (r"/story/([0-9]+)", StoryHandler), ]) • Post arguments class MainHandler(tornado.web.RequestHandler): def get(self): self.write('<html><body><form action="/" method="post">' '<input type="text" name="message">' '<input type="submit" value="Submit">' '</form></body></html>') def post(self): self.set_header("Content-Type", "text/plain") self.write("You wrote " + self.get_argument("message")) • HTTPRequest
  • 6. - Code Snippets • HTML Templates <html> <head> <title>{{ title }}</title> </head> <body> <ul> {% for item in items %} <li>{{ escape(item) }}</li> {% end %} </ul> </body> </html> • Template Handler class MainHandler(tornado.web.RequestHandler): def get(self): Items = ["Item 1", "Item 2", "Item 3"] self.render("template.html", title="My title", items=items)
  • 7. - UI Modules Blog Post 1 myModule.py <short python code here…> Blog Post 2 Web Page
  • 8. - Asynchronous Requests 1. Fetch data www.website.com Picasa/Flickr 2. Response (callback) Synchronous Requests • immediate server response • cannot later-update the client Asynchronous Requests • immediate server response • allows for 3rd party services • push technologies
  • 9. - References Non-blocking Long-polling Asynchronous Tornado Epoll man page Long Pooling CSRF - modular CSRF Protection Web Server Signed Cookies http://www.tornadoweb.org/ http://linux.die.net/man/4/epoll http://en.wikipedia.org/wiki/Push_technology http://en.wikipedia.org/wiki/Cross-site_request_forgery Q/A minute Hack it now…
  • 10. http://www.slideshare.net/ConstantinePriemski/tornado Thank YOU!

×