Tornado

4,506 views

Published on

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

No Downloads
Views
Total views
4,506
On SlideShare
0
From Embeds
0
Number of Embeds
36
Actions
Shares
0
Downloads
66
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide
  • - Facebook Tornado (ce este tornado, structura de ansamblu a modulelor, care sunt beneficiile, cum se utilizeaza)- Rata de adoptie pe web a tehnologiilor (weekend sized-problem)
  • Cati au cont pe faceboook?Stie cineva ce e friendfeed?La ce foloseste?Acquisition price, value baby (Tornado)
  • - Ce e tornado in esenta?blocking vs non-blocking- Select O(n) , epoll O(1)- Real time web services: search, news, contacts
  • Tornado

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

    ×