SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Introduction to Tornado
Nguyen Anh Tien – 2013/06/08
● Python web server
framework
● FriendFeed
– http://friendfeed.com/
● Facebook, Bret Taylor
● Scalable
● Non-blocking I/O
What is Tornado ?
https://github.com/facebook/tornado
http://www.tornadoweb.org/
Some services use Tornado
How to install
● Lazy way
– sudo apt-get install python-setuptools
– sudo easy_install tornado
Famous “Hello, world” Example
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
Code breaking (1)
application = tornado.web.Application([
(r"/", MainHandler),
])
● Request to root path is handled by class MainHandler
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
● Implement GET function to handle GET request
Code breaking (2)
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
● Start server listen at port 8888
● Simple, doesn't it ?
Features - Templates
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
<ul>
{% for item in items %}
<li>{{ escape(item) }}</li>
{% end %}
</ul>
</body>
</html>
class MainHandler(tornado.web.RequestHandler):
def get(self):
items = ["First item", "Second", "Last One"]
self.render(
"template.html",
title="My title",
items=items
)
Features – Authentication
● Signed secure cookie
● Third party authentication
– Facebook
– Twitter
– Google
– OAuth
Features - Others
● Localization
● Cross-site request forgery protection
● Static file
● Caching
● ...
Blocking I/O
Non blocking I/O
Tornado is ideal for
● Long polling service
– Keep-alive connection, real-time
● A lot of user
→ Chat Server, Notification Sever
● I/O intensive tasks
● Write super fast web applications quickly and
easily
Tornado is not for
● Complex CMS service, full MVC features
→ Django is a good choice
● Computational intensive tasks
Demo
● Chat server
– At 192.168.1.37:1234
● Twitter recent post count
Reference
● Introduction to Tornado –
O'Reilly Media
● http://www.tornadoweb.org
● https://github.com/Introduction-to-Tornado
● https://github.com/facebook/tornado
● http://www.slideshare.net/kurtiss/tornado-web

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (18)

androidstudio.pptx
androidstudio.pptxandroidstudio.pptx
androidstudio.pptx
 
Smart home with home automation
Smart home with home automationSmart home with home automation
Smart home with home automation
 
Android Web app
Android Web app Android Web app
Android Web app
 
Google assistant
Google assistantGoogle assistant
Google assistant
 
Flutter technology Based on Web Development
Flutter technology Based on Web Development Flutter technology Based on Web Development
Flutter technology Based on Web Development
 
Smart home automation
Smart home automationSmart home automation
Smart home automation
 
Health monitoring system
Health monitoring systemHealth monitoring system
Health monitoring system
 
Honeypot Basics
Honeypot BasicsHoneypot Basics
Honeypot Basics
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - Intent
 
What is botnet?
What is botnet?What is botnet?
What is botnet?
 
android content providers
android content providersandroid content providers
android content providers
 
El lado oscuro de Tor: la deep web
El lado oscuro de Tor: la deep webEl lado oscuro de Tor: la deep web
El lado oscuro de Tor: la deep web
 
Introduction to Home Automation
Introduction to Home AutomationIntroduction to Home Automation
Introduction to Home Automation
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Broadcast receivers
Broadcast receiversBroadcast receivers
Broadcast receivers
 
Android Fragment
Android FragmentAndroid Fragment
Android Fragment
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Home automation
Home automationHome automation
Home automation
 

Andere mochten auch

Tornado - different Web programming
Tornado - different Web programmingTornado - different Web programming
Tornado - different Web programmingDima Malenko
 
Real time server
Real time serverReal time server
Real time serverthepian
 
Audited activerecord - QuanHV
Audited activerecord - QuanHVAudited activerecord - QuanHV
Audited activerecord - QuanHVFramgia Vietnam
 
Rapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodbRapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodbikailan
 
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...Mehmet Köse
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011hangxin1940
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用Felinx Lee
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Asynchronous programming in Python
Asynchronous programming in PythonAsynchronous programming in Python
Asynchronous programming in PythonAurynn Shaw
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server InternalsPraveen Gollakota
 
Tornado web
Tornado webTornado web
Tornado webkurtiss
 

Andere mochten auch (14)

Tornado
TornadoTornado
Tornado
 
Tornado
TornadoTornado
Tornado
 
Tornado - different Web programming
Tornado - different Web programmingTornado - different Web programming
Tornado - different Web programming
 
Tornadoweb
TornadowebTornadoweb
Tornadoweb
 
Real time server
Real time serverReal time server
Real time server
 
Audited activerecord - QuanHV
Audited activerecord - QuanHVAudited activerecord - QuanHV
Audited activerecord - QuanHV
 
Rapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodbRapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodb
 
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
Özgür Web Günleri 2013 | Python + Tornado + Nginx + Mongodb ile Ölçeklenebili...
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011
 
用Tornado开发RESTful API运用
用Tornado开发RESTful API运用用Tornado开发RESTful API运用
用Tornado开发RESTful API运用
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Asynchronous programming in Python
Asynchronous programming in PythonAsynchronous programming in Python
Asynchronous programming in Python
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
 
Tornado web
Tornado webTornado web
Tornado web
 

Ähnlich wie Introduction to Tornado - TienNA

Integrating tornado and webpack
Integrating tornado and webpackIntegrating tornado and webpack
Integrating tornado and webpackTom Chen
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in DjangoLakshman Prasad
 
Java - A broad introduction
Java - A broad introductionJava - A broad introduction
Java - A broad introductionBirol Efe
 
C4ainaction-Introduction to the Pyramid Web Framework
C4ainaction-Introduction to the Pyramid Web FrameworkC4ainaction-Introduction to the Pyramid Web Framework
C4ainaction-Introduction to the Pyramid Web FrameworkFrancis Addai
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoAhmed Salama
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
MenloHacks Workshop 2019
MenloHacks Workshop 2019MenloHacks Workshop 2019
MenloHacks Workshop 2019Bruce Lin
 
.NET @ apache.org
 .NET @ apache.org .NET @ apache.org
.NET @ apache.orgTed Husted
 
Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020César Hernández
 
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group   nov 8th - drupal 7.32 security vulnerabilityHong kong drupal user group   nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerabilityAnn Lam
 
Hong Kong Drupal User Group - Nov 8th
Hong Kong Drupal User Group - Nov 8thHong Kong Drupal User Group - Nov 8th
Hong Kong Drupal User Group - Nov 8thWong Hoi Sing Edison
 
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group   nov 8th - drupal 7.32 security vulnerabilityHong kong drupal user group   nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerabilityAnn Lam
 
Aandroid coding convention and quality assurance plugin
Aandroid coding convention and quality assurance pluginAandroid coding convention and quality assurance plugin
Aandroid coding convention and quality assurance pluginDuy Tan Geek
 
An introduction to Node.js application development
An introduction to Node.js application developmentAn introduction to Node.js application development
An introduction to Node.js application developmentshelloidhq
 
Performance #6 threading
Performance #6  threadingPerformance #6  threading
Performance #6 threadingVitali Pekelis
 

Ähnlich wie Introduction to Tornado - TienNA (20)

Integrating tornado and webpack
Integrating tornado and webpackIntegrating tornado and webpack
Integrating tornado and webpack
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
Java - A broad introduction
Java - A broad introductionJava - A broad introduction
Java - A broad introduction
 
java applets
java appletsjava applets
java applets
 
C4ainaction-Introduction to the Pyramid Web Framework
C4ainaction-Introduction to the Pyramid Web FrameworkC4ainaction-Introduction to the Pyramid Web Framework
C4ainaction-Introduction to the Pyramid Web Framework
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Pyramid Framework
Pyramid FrameworkPyramid Framework
Pyramid Framework
 
MenloHacks Workshop 2019
MenloHacks Workshop 2019MenloHacks Workshop 2019
MenloHacks Workshop 2019
 
Android networking-2
Android networking-2Android networking-2
Android networking-2
 
.NET @ apache.org
 .NET @ apache.org .NET @ apache.org
.NET @ apache.org
 
Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Applets
AppletsApplets
Applets
 
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group   nov 8th - drupal 7.32 security vulnerabilityHong kong drupal user group   nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability
 
Hong Kong Drupal User Group - Nov 8th
Hong Kong Drupal User Group - Nov 8thHong Kong Drupal User Group - Nov 8th
Hong Kong Drupal User Group - Nov 8th
 
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group   nov 8th - drupal 7.32 security vulnerabilityHong kong drupal user group   nov 8th - drupal 7.32 security vulnerability
Hong kong drupal user group nov 8th - drupal 7.32 security vulnerability
 
Aandroid coding convention and quality assurance plugin
Aandroid coding convention and quality assurance pluginAandroid coding convention and quality assurance plugin
Aandroid coding convention and quality assurance plugin
 
An introduction to Node.js application development
An introduction to Node.js application developmentAn introduction to Node.js application development
An introduction to Node.js application development
 
Performance #6 threading
Performance #6  threadingPerformance #6  threading
Performance #6 threading
 

Mehr von Framgia Vietnam

Functional Programming With Elixir
Functional Programming With ElixirFunctional Programming With Elixir
Functional Programming With ElixirFramgia Vietnam
 
Timeless - Websocket on Rails
Timeless - Websocket on RailsTimeless - Websocket on Rails
Timeless - Websocket on RailsFramgia Vietnam
 
Game Development with Pygame
Game Development with PygameGame Development with Pygame
Game Development with PygameFramgia Vietnam
 
CSS3 Lovers, Gather Together
CSS3 Lovers, Gather TogetherCSS3 Lovers, Gather Together
CSS3 Lovers, Gather TogetherFramgia Vietnam
 
Build public private cloud using openstack
Build public private cloud using openstackBuild public private cloud using openstack
Build public private cloud using openstackFramgia Vietnam
 
Introduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on RailsIntroduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on RailsFramgia Vietnam
 
Some ways to DRY in Rails
Some ways to DRY in Rails Some ways to DRY in Rails
Some ways to DRY in Rails Framgia Vietnam
 
Create 3D objects insite Cocos2d-x
Create 3D objects insite Cocos2d-xCreate 3D objects insite Cocos2d-x
Create 3D objects insite Cocos2d-xFramgia Vietnam
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptFramgia Vietnam
 
Organize directories for applications with front-end and back-end with yii - ...
Organize directories for applications with front-end and back-end with yii - ...Organize directories for applications with front-end and back-end with yii - ...
Organize directories for applications with front-end and back-end with yii - ...Framgia Vietnam
 
What is new in PHP 5.5 - HuyenNT
What is new in PHP 5.5 - HuyenNTWhat is new in PHP 5.5 - HuyenNT
What is new in PHP 5.5 - HuyenNTFramgia Vietnam
 
Client side validations gem - KhanhHD
Client side validations gem - KhanhHDClient side validations gem - KhanhHD
Client side validations gem - KhanhHDFramgia Vietnam
 
Backbone.js and rails - BanLV
Backbone.js and rails - BanLVBackbone.js and rails - BanLV
Backbone.js and rails - BanLVFramgia Vietnam
 
Jenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuJenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuFramgia Vietnam
 

Mehr von Framgia Vietnam (20)

Functional Programming With Elixir
Functional Programming With ElixirFunctional Programming With Elixir
Functional Programming With Elixir
 
Dreamers defense
Dreamers defenseDreamers defense
Dreamers defense
 
Timeless - Websocket on Rails
Timeless - Websocket on RailsTimeless - Websocket on Rails
Timeless - Websocket on Rails
 
Game Development with Pygame
Game Development with PygameGame Development with Pygame
Game Development with Pygame
 
Racer Mice - Game Team
Racer Mice - Game TeamRacer Mice - Game Team
Racer Mice - Game Team
 
CSS3 Lovers, Gather Together
CSS3 Lovers, Gather TogetherCSS3 Lovers, Gather Together
CSS3 Lovers, Gather Together
 
Java 8 new features
Java 8 new features Java 8 new features
Java 8 new features
 
Build public private cloud using openstack
Build public private cloud using openstackBuild public private cloud using openstack
Build public private cloud using openstack
 
Introduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on RailsIntroduction to JRuby And JRuby on Rails
Introduction to JRuby And JRuby on Rails
 
Some ways to DRY in Rails
Some ways to DRY in Rails Some ways to DRY in Rails
Some ways to DRY in Rails
 
HTML5 DRAG AND DROP
HTML5 DRAG AND DROPHTML5 DRAG AND DROP
HTML5 DRAG AND DROP
 
Create 3D objects insite Cocos2d-x
Create 3D objects insite Cocos2d-xCreate 3D objects insite Cocos2d-x
Create 3D objects insite Cocos2d-x
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
 
Organize directories for applications with front-end and back-end with yii - ...
Organize directories for applications with front-end and back-end with yii - ...Organize directories for applications with front-end and back-end with yii - ...
Organize directories for applications with front-end and back-end with yii - ...
 
What is new in PHP 5.5 - HuyenNT
What is new in PHP 5.5 - HuyenNTWhat is new in PHP 5.5 - HuyenNT
What is new in PHP 5.5 - HuyenNT
 
An idea - NghiaLV
An idea - NghiaLVAn idea - NghiaLV
An idea - NghiaLV
 
Delegate - KhanhLD
Delegate - KhanhLDDelegate - KhanhLD
Delegate - KhanhLD
 
Client side validations gem - KhanhHD
Client side validations gem - KhanhHDClient side validations gem - KhanhHD
Client side validations gem - KhanhHD
 
Backbone.js and rails - BanLV
Backbone.js and rails - BanLVBackbone.js and rails - BanLV
Backbone.js and rails - BanLV
 
Jenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuJenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh Vu
 

Kürzlich hochgeladen

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Kürzlich hochgeladen (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

Introduction to Tornado - TienNA

  • 1. Introduction to Tornado Nguyen Anh Tien – 2013/06/08
  • 2. ● Python web server framework ● FriendFeed – http://friendfeed.com/ ● Facebook, Bret Taylor ● Scalable ● Non-blocking I/O What is Tornado ? https://github.com/facebook/tornado http://www.tornadoweb.org/
  • 4. How to install ● Lazy way – sudo apt-get install python-setuptools – sudo easy_install tornado
  • 5. Famous “Hello, world” Example import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world") application = tornado.web.Application([ (r"/", MainHandler), ]) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start()
  • 6. Code breaking (1) application = tornado.web.Application([ (r"/", MainHandler), ]) ● Request to root path is handled by class MainHandler class MainHandler(tornado.web.RequestHandler): def get(self): self.write("Hello, world") ● Implement GET function to handle GET request
  • 7. Code breaking (2) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start() ● Start server listen at port 8888 ● Simple, doesn't it ?
  • 8.
  • 9. Features - Templates <html> <head> <title>{{ title }}</title> </head> <body> <ul> {% for item in items %} <li>{{ escape(item) }}</li> {% end %} </ul> </body> </html> class MainHandler(tornado.web.RequestHandler): def get(self): items = ["First item", "Second", "Last One"] self.render( "template.html", title="My title", items=items )
  • 10. Features – Authentication ● Signed secure cookie ● Third party authentication – Facebook – Twitter – Google – OAuth
  • 11. Features - Others ● Localization ● Cross-site request forgery protection ● Static file ● Caching ● ...
  • 14. Tornado is ideal for ● Long polling service – Keep-alive connection, real-time ● A lot of user → Chat Server, Notification Sever ● I/O intensive tasks ● Write super fast web applications quickly and easily
  • 15. Tornado is not for ● Complex CMS service, full MVC features → Django is a good choice ● Computational intensive tasks
  • 16. Demo ● Chat server – At 192.168.1.37:1234 ● Twitter recent post count
  • 17. Reference ● Introduction to Tornado – O'Reilly Media ● http://www.tornadoweb.org ● https://github.com/Introduction-to-Tornado ● https://github.com/facebook/tornado ● http://www.slideshare.net/kurtiss/tornado-web

Hinweis der Redaktion

  1. Handling many thousands concurrent requests is usually costly because the server needs to spawn threads to handle these and threads aren&apos;t that cheap The libraries you use have to be thread safe, meaning that multiple threads should be able to use them concurrently
  2. Handling many thousands of concurrent requests isn&apos;t a problem and non-blocking servers excel at this and the reason why they are used for Comet Everything performed in the IO loop has to be non-blocking, else the IO loop gets blocked and your server will stall until this blocking operation is complete Thread safety isn&apos;t an issue