SlideShare a Scribd company logo
quick’n’dirty
TORNADO intro

                   Teemu Kurppa
           www.dirtyaura.org/blog
                   Twitter: teemu

                Huikea Experience
       Social mobile gaming startup
                  www.huikea.com
Quick'n'Dirty Tornado Intro
TORNADO


 scalable, non-blocking web server
TORNADO
  asynchronous requests
  simple clean DB API, no ORM
  programmer-friendly templates
  readable codebase
  proven in production: FriendFeed
TORNADO
Probably good for
real-time web services (hanging GETs to poll)
super-popular dynamic sites
non-web REST services
non-CMS sites
for devs like me
Our Tornado instance
               app



cheap, async call


                    Twitter
Our Tornado instance
db.slow_synchronous_query()

 cheap, async call
                               ?
                     Twitter
Our Tornado instance



               cheap, async calls

  Another Tornado instance
                                    Twitter
db.slow_synchronous_query()
Programmer-friendly templates


    {% for index,value in entries.iteritems() %}
      {{ index }} : {{ value }
    {% end %}


    {% for value in entries %}
      {{ forloop.counter0 }} : {{ value }}
    {% endfor %}
CODE DEMO
class TwitterBadgeHandler(tornado.web.RequestHandler):
   @tornado.web.asynchronous
   def get(self, username):
      http = tornado.httpclient.AsyncHTTPClient()
      url = "http://api.twitter.com/1/users/show/%s.json" % username
      http.fetch(url, callback=self.on_response)

  def on_response(self, response):
    if response.error:
        self.render("badge_error.html")
    else:
        user = tornado.escape.json_decode(response.body)
        self.render("twitter_badge.html", **user)
....
    <style type="text/css">
      .badge {
         background: #{{profile_background_color}} url({{profile_background_image_url}});

... rest of wrapping and css left-out ...

  <div class="badge">
   <img class="badge-photo” src="{{ profile_image_url }}">
   <div class="badge-title">{{ screen_name }}</div>
   <div class="badge-description">{{ description }}</div>
   <div class="clear"></div>
   <div class="badge-status">{{ status['text'] }}</div>
  </div>
Quick'n'Dirty Tornado Intro

More Related Content

PPTX
Setting UIAutomation free with Appium
PPTX
Tornado PowerPoint
PPTX
Phl mongo-philly-tornado-2011
PPT
Robotlegs on Top of Gaia
PPTX
Tornado web
PDF
REST and some Python (or 'Python "sinners" must REST')
PPTX
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
Setting UIAutomation free with Appium
Tornado PowerPoint
Phl mongo-philly-tornado-2011
Robotlegs on Top of Gaia
Tornado web
REST and some Python (or 'Python "sinners" must REST')
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho

Similar to Quick'n'Dirty Tornado Intro (20)

PDF
Rails missing features
PPT
Real time server
KEY
Motion Django Meetup
PDF
Exploring Async PHP (SF Live Berlin 2019)
PDF
Integrating WordPress With Web APIs
PPTX
Develop iOS and Android apps with SharePoint/Office 365
PDF
Building TweetEngine
PDF
Reactive Application Using METEOR
PDF
PDF
Web performance optimization
PPTX
Monitoring distributed (micro-)services
PPTX
Reactive application using meteor
PPT
Rhodes Overview
PDF
Rust: Systems Programming for Everyone
PDF
Using Sinatra to Build REST APIs in Ruby
PDF
Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...
PDF
Introduction to CloudStack API
PPTX
Service Discovery using etcd, Consul and Kubernetes
PDF
CloudWatch hidden features for debugging serverless application
PDF
Pentesting RESTful webservices
Rails missing features
Real time server
Motion Django Meetup
Exploring Async PHP (SF Live Berlin 2019)
Integrating WordPress With Web APIs
Develop iOS and Android apps with SharePoint/Office 365
Building TweetEngine
Reactive Application Using METEOR
Web performance optimization
Monitoring distributed (micro-)services
Reactive application using meteor
Rhodes Overview
Rust: Systems Programming for Everyone
Using Sinatra to Build REST APIs in Ruby
Think Async: Understanding the Complexity of Multithreading - Avi Kabizon & A...
Introduction to CloudStack API
Service Discovery using etcd, Consul and Kubernetes
CloudWatch hidden features for debugging serverless application
Pentesting RESTful webservices
Ad

More from Teemu Kurppa (7)

PDF
React + Redux + d3.js
PDF
fast.ai - Learning Deep Learning
PDF
Managing data workflows with Luigi
KEY
Early stage startups
PDF
Mobile Startups - Why to focus on mobile?
PDF
Platform = Stage. How to choose a mobile development platform?
PDF
Leaks & Zombies
React + Redux + d3.js
fast.ai - Learning Deep Learning
Managing data workflows with Luigi
Early stage startups
Mobile Startups - Why to focus on mobile?
Platform = Stage. How to choose a mobile development platform?
Leaks & Zombies
Ad

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
project resource management chapter-09.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
Programs and apps: productivity, graphics, security and other tools
SOPHOS-XG Firewall Administrator PPT.pptx
WOOl fibre morphology and structure.pdf for textiles
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Web App vs Mobile App What Should You Build First.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Group 1 Presentation -Planning and Decision Making .pptx
TLE Review Electricity (Electricity).pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
A Presentation on Artificial Intelligence
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Tartificialntelligence_presentation.pptx
Enhancing emotion recognition model for a student engagement use case through...
Univ-Connecticut-ChatGPT-Presentaion.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
project resource management chapter-09.pdf
A comparative analysis of optical character recognition models for extracting...
NewMind AI Weekly Chronicles - August'25-Week II

Quick'n'Dirty Tornado Intro

  • 1. quick’n’dirty TORNADO intro Teemu Kurppa www.dirtyaura.org/blog Twitter: teemu Huikea Experience Social mobile gaming startup www.huikea.com
  • 4. TORNADO asynchronous requests simple clean DB API, no ORM programmer-friendly templates readable codebase proven in production: FriendFeed
  • 5. TORNADO Probably good for real-time web services (hanging GETs to poll) super-popular dynamic sites non-web REST services non-CMS sites for devs like me
  • 6. Our Tornado instance app cheap, async call Twitter
  • 8. Our Tornado instance cheap, async calls Another Tornado instance Twitter db.slow_synchronous_query()
  • 9. Programmer-friendly templates {% for index,value in entries.iteritems() %} {{ index }} : {{ value } {% end %} {% for value in entries %} {{ forloop.counter0 }} : {{ value }} {% endfor %}
  • 11. class TwitterBadgeHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self, username): http = tornado.httpclient.AsyncHTTPClient() url = "http://api.twitter.com/1/users/show/%s.json" % username http.fetch(url, callback=self.on_response) def on_response(self, response): if response.error: self.render("badge_error.html") else: user = tornado.escape.json_decode(response.body) self.render("twitter_badge.html", **user)
  • 12. .... <style type="text/css"> .badge { background: #{{profile_background_color}} url({{profile_background_image_url}}); ... rest of wrapping and css left-out ... <div class="badge"> <img class="badge-photo” src="{{ profile_image_url }}"> <div class="badge-title">{{ screen_name }}</div> <div class="badge-description">{{ description }}</div> <div class="clear"></div> <div class="badge-status">{{ status['text'] }}</div> </div>