SlideShare a Scribd company logo
1 of 10
Real-time Webserving ,[object Object]
Lean Basics ,[object Object]
[object Object],[object Object],[object Object],[object Object],Web User Scenarios
Server Startup Multi sub-domain, auto-reloading process Multi sub-domain, auto-reloading process ioloop = tornado.ioloop.IOLoop.instance()  for n in structure.SITES:  site = structure.SITES[n]  if site["package"] in ("tornado", "mediaserver"):  server = HTTPServer( Application (urls,site,ioloop=ioloop))  server.listen(site["port"])  tornado.autoreload.start(io_loop=ioloop)  ioloop.start()
Handle Request urls = [ (r"/static/(.*)", StaticFileHandler),] class MyHandler(tornado. web.RequestHandler ):  def get(self,subpath): info = { “ abc_list”: [“a”, ”b”, ”c”], “ path”: self.request.path, “ subpath”: subpath }  self.render("home.html",**info)  def post(self,subpath):  post_names = self.request.arguments.keys() headers_dict = self.request.headers headers_dict = self.request.headers
Serve Response class MyHandler(tornado. web.RequestHandler ):  def get(self,subpath): site_title = self.application.site["title"]  info = { “ abc_list”: [“a”, ”b”, ”c”], “ site_title”: site_title }  self.render("home.html",**info) def post(self):  post_names = self.request.arguments.keys():  self.set_header("Content-Type","text/plain")  self.write('done.')
Delayed Response class MainHandler(tornado. web.RequestHandler ):  @ tornado. web.asynchronous     def get(self):   http = tornado.httpclient.AsyncHTTPClient()  http.fetch(" http://friendfeed-api.com/v2/feed/ bret ",                   callback=self .async_callback( self.on_response ))  def on_response(self, response):  if response.error: raise tornado. web.HTTPError (500)  json = tornado.escape.json_decode(response.bod y)        sel f.write("Fetched " + str(len(json["entries"])) + " entries "  "from the FriendFeed API")  self.finish ()
Baseline Performance ,[object Object]
Henrik Vendelbo ,[object Object],[object Object]
Baseline Performance ,[object Object]

More Related Content

What's hot

Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
Michael Peacock
 
Powerful and flexible templates with Twig
Powerful and flexible templates with Twig Powerful and flexible templates with Twig
Powerful and flexible templates with Twig
Michael Peacock
 

What's hot (20)

Tornadoweb
TornadowebTornadoweb
Tornadoweb
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rack
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
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
 
Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011Phl mongo-philly-tornado-2011
Phl mongo-philly-tornado-2011
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
 
Powerful and flexible templates with Twig
Powerful and flexible templates with Twig Powerful and flexible templates with Twig
Powerful and flexible templates with Twig
 
New in php 7
New in php 7New in php 7
New in php 7
 
Even faster django
Even faster djangoEven faster django
Even faster django
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
 
Building a real life application in node js
Building a real life application in node jsBuilding a real life application in node js
Building a real life application in node js
 
Webrtc mojo
Webrtc mojoWebrtc mojo
Webrtc mojo
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
HTTP Caching and PHP
HTTP Caching and PHPHTTP Caching and PHP
HTTP Caching and PHP
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Perl: Hate it for the Right Reasons
Perl: Hate it for the Right ReasonsPerl: Hate it for the Right Reasons
Perl: Hate it for the Right Reasons
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 

Similar to Real time server

Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 

Similar to Real time server (20)

Tornado
TornadoTornado
Tornado
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Using WordPress as your application stack
Using WordPress as your application stackUsing WordPress as your application stack
Using WordPress as your application stack
 
Rack
RackRack
Rack
 
And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
 
Diseño y Desarrollo de APIs
Diseño y Desarrollo de APIsDiseño y Desarrollo de APIs
Diseño y Desarrollo de APIs
 
Frontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and HowFrontend Servers and NGINX: What, Where and How
Frontend Servers and NGINX: What, Where and How
 
Hammock, a Good Place to Rest
Hammock, a Good Place to RestHammock, a Good Place to Rest
Hammock, a Good Place to Rest
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
Intro to Node
Intro to NodeIntro to Node
Intro to Node
 
Rpi python web
Rpi python webRpi python web
Rpi python web
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 
Gears User Guide
Gears User GuideGears User Guide
Gears User Guide
 
Web program-peformance-optimization
Web program-peformance-optimizationWeb program-peformance-optimization
Web program-peformance-optimization
 
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディングXitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
Xitrum Web Framework Live Coding Demos / Xitrum Web Framework ライブコーディング
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
 

Recently uploaded

Recently uploaded (20)

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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

Real time server

  • 1.
  • 2.
  • 3.
  • 4. Server Startup Multi sub-domain, auto-reloading process Multi sub-domain, auto-reloading process ioloop = tornado.ioloop.IOLoop.instance() for n in structure.SITES: site = structure.SITES[n] if site["package"] in ("tornado", "mediaserver"): server = HTTPServer( Application (urls,site,ioloop=ioloop)) server.listen(site["port"]) tornado.autoreload.start(io_loop=ioloop) ioloop.start()
  • 5. Handle Request urls = [ (r"/static/(.*)", StaticFileHandler),] class MyHandler(tornado. web.RequestHandler ): def get(self,subpath): info = { “ abc_list”: [“a”, ”b”, ”c”], “ path”: self.request.path, “ subpath”: subpath } self.render("home.html",**info) def post(self,subpath): post_names = self.request.arguments.keys() headers_dict = self.request.headers headers_dict = self.request.headers
  • 6. Serve Response class MyHandler(tornado. web.RequestHandler ): def get(self,subpath): site_title = self.application.site["title"] info = { “ abc_list”: [“a”, ”b”, ”c”], “ site_title”: site_title } self.render("home.html",**info) def post(self): post_names = self.request.arguments.keys(): self.set_header("Content-Type","text/plain") self.write('done.')
  • 7. Delayed Response class MainHandler(tornado. web.RequestHandler ): @ tornado. web.asynchronous def get(self): http = tornado.httpclient.AsyncHTTPClient() http.fetch(" http://friendfeed-api.com/v2/feed/ bret ", callback=self .async_callback( self.on_response )) def on_response(self, response): if response.error: raise tornado. web.HTTPError (500) json = tornado.escape.json_decode(response.bod y) sel f.write("Fetched " + str(len(json["entries"])) + " entries " "from the FriendFeed API") self.finish ()
  • 8.
  • 9.
  • 10.