SlideShare a Scribd company logo
1 of 33
Download to read offline
●   Tornado, Friendfeed'in kullandığı non-blocking
    (bkz:non blocking) ve ölçeklenebilir web
    araçlarının adıdır.

●   Facebook, Friendfeed'i satın aldıktan Apache
    lisansı ile açık kaynak olarak dağıtılmaya
    başlandı.
| Kurulum
wget -c http://github.com/downloads/facebook/tornado/tornado-1.0.tar.gz
tar xvzf tornado-1.0.tar.gz
cd tornado-1.0
python setup.py build
sudo python setup.py install


Veya


apt-get install pyton-tornado (debian sid)
| Performans
●   'Hello world' performansı
| Modüller
           High Level Modüller                 Low level modüller
●   web                           ●   httpserver
●   escape                        ●   iostream
●   database                      ●   İoloop
●   template
●   httpclient
●   auth
●   locale                        ●   epoll
●   options
| web
Friendfeed'in üzerine kurulduğu, başlıca ana
           parçaları içeren modül
| escape
XHTML, JSON ve URL encode/decode işlemleri
              için modüller
| database
MySQLdb modülü üzerine geliştirilmiş bir wrapper
| template
Şablon motoru
| auth
         3. parti kimlik doğrulama kütüphaneleri
(Google OpenID/OAuth, Facebook Platform, Yahoo BBAuth,
        FriendFeed OpenID/OAuth, Twitter OAuth)
| locale
Yerelleştirme desteği için modül
| options
Komut satırından veya yapılandırma dosyasından
   yapılandırma almak için modül (optparser)
| low level
Bunların altında ise esas non-blocking işlemleri yapan
●   httpserver : non-blocking http sunucu
●   iostream : non-blocking socketleri okumak için geliştirilmiş bir modül
●   ioloop : ana i/o modülü




●   Bir de amazon s3 simüle eden bir sunucu modülü var.
| kod örnekleri

http://github.com/yuxel/snippets/tree/master/python/tornado/
#!/usr/bin/python
                                                                | hello world
import tornado.httpserver
import tornado.ioloop
import tornado.web


class HelloHandler(tornado.web.RequestHandler):
     def get(self):
       self.write("Hello World")


application = tornado.web.Application([
     (r"/", HelloHandler),
])


if __name__ == "__main__":
     http_server = tornado.httpserver.HTTPServer(application)
     http_server.listen(8888)
     tornado.ioloop.IOLoop.instance().start()



             http://github.com/yuxel/snippets/blob/master/python/tornado/helloWorld.py
.....
                                              | request handling
# handles pages matches URI /another/someUriParam
class AnotherHandler(tornado.web.RequestHandler):
     def get(self,uriParam):
         self.write("This is another page with URI parameter = " + uriParam)


application = tornado.web.Application([
     (r"/another/([^/]+)", AnotherHandler),
])


....


        http://github.com/yuxel/snippets/blob/master/python/tornado/requestHandling.py
...
                                                                | request handling
# handles pages matches /postTest/ and demonstrate getting request parameter
class PostSomethingHandler(tornado.web.RequestHandler):
      def get(self):
        form = """<form method="post">
        <input type="text" name="something"/>
        <input type="submit"/>
        </form>"""
        self.write(form)


      def post(self):
        postedValue = self.get_argument("something") # get request argument
        self.write("You've postted 'something' as : " + postedValue)



application = tornado.web.Application([
      (r"/postTest/", PostSomethingHandler),
])
...


         http://github.com/yuxel/snippets/blob/master/python/tornado/requestHandling.py
...
                                            | request handling
# demonstrates an HTTP response error
class ResponseErrorHandler(tornado.web.RequestHandler):
      def get(self):
        # send a 403 forbidden error
        raise tornado.web.HTTPError(403)



application = tornado.web.Application([
      (r"/someError/", ResponseErrorHandler),
])


...


       http://github.com/yuxel/snippets/blob/master/python/tornado/requestHandling.py
...
                                                         | cookie
# demonstrates cookie usage
class MainHandler(tornado.web.RequestHandler):
      def get(self):
        cookieName = "pyist";
        cookieValue = self.get_cookie(cookieName)
        currentTimestamp = str(time.time())
        if not cookieValue:
           self.set_cookie(cookieName, currentTimestamp)
           self.write("I've just set your cookie, refresh!")
        else:
           self.write("Cookie value : " + cookieValue)



...



                http://github.com/yuxel/snippets/blob/master/python/tornado/cookie.py
...
                                                         | secure cookie
# demonstrates secure cookie example
class SecureCookieHandler(tornado.web.RequestHandler):
      def get(self):
        cookieName = "pyist_secure";
        cookieValue = self.get_secure_cookie(cookieName)
        currentTimestamp = str(time.time())
        if not cookieValue:
           self.set_secure_cookie(cookieName, currentTimestamp)
           self.write("I've just set your cookie, refresh!")
        else:
           self.write("Cookie value : " + cookieValue)



...



                http://github.com/yuxel/snippets/blob/master/python/tornado/cookie.py
...
<!DOCTYPE html>
                                                 | template
<html>
      <head>
        <title>{{ title }}</title>
        <meta charset="utf-8" />
      </head>
      <body>
        {% if userLogged %}
           Hi {{ userLogged }}
        {% else %}
           You need to log in to see this page
        {% end %}
      </body>
</html>




...



        http://github.com/yuxel/snippets/blob/master/python/tornado/templates/main.html
...
                                                | template
# handles main page
class MainHandler(tornado.web.RequestHandler):
      def get(self):
        #we demonstrate this using a ?userLogged=userName parameter
        switchLoggedFromGet = self.get_argument("userLogged", False)


        #remove html entities
        switchLoggedFromGet = tornado.escape.xhtml_escape(switchLoggedFromGet)


        self.render("templates/main.html", title="Pyist.net", userLogged=switchLoggedFromGet)



...


            http://github.com/yuxel/snippets/blob/master/python/tornado/template.py
...
                                                           | locale
class TRHandler(tornado.web.RequestHandler):
      def get(self):
        tornado.locale.set_default_locale('tr_TR')
        self.render("templates/translation.html")


# English page
class ENHandler(tornado.web.RequestHandler):
      def get(self):
        tornado.locale.set_default_locale('en_US')
        self.render("templates/translation.html")
...
if __name__ == "__main__":
      #set path for location dir
      translationsPath = os.path.join(os.path.dirname(__file__), "translations")
      tornado.locale.load_translations(translationsPath)
...

            http://github.com/yuxel/snippets/blob/master/python/tornado/translation.py
tr_TR.csv
                                      | locale
"Hello World!","Merhaba dunya!"
"This is another test","Bu bir test"



en_EN.csv
"Hello World!","Hello, world!"
"This is another test","This is another test"

     http://github.com/yuxel/snippets/blob/master/python/tornado/translations
...
                                                    | xsrf koruması
# handles main page
class MainHandler(tornado.web.RequestHandler):
      def get(self):
        self.render("templates/xsrf.html")


      # if _xsrf value doesnt match xsrf cookie value, this will return 403
      def post(self):
        postedValue = self.get_argument("something") # get request argument
        self.write("You've postted 'something' as : " + postedValue)


application = tornado.web.Application([
      (r"/", MainHandler),
], cookie_secret="SomeSecret",xsrf_cookies=True)
...

               http://github.com/yuxel/snippets/blob/master/python/tornado/xsrf.py
| xsrf koruması
<!DOCTYPE html>
<html>
  <head>
    <title>Pyist Tornadoweb</title>
    <meta charset="utf-8" />
  </head>
  <body>
    <form action="" method="post">
     {{ xsrf_form_html() }}
     <div>
         Write something: <input type="text" name="something"/>
         <input type="submit" value="Try"/>
     </div>
    </form>
  </body>
</html>

    http://github.com/yuxel/snippets/blob/master/python/tornado/templates/xsrf.html
import tornado.httpclient
                                                             | asenkron istekler
...
class MainHandler(tornado.web.RequestHandler):
      @tornado.web.asynchronous
      def get(self):
        http = tornado.httpclient.AsyncHTTPClient()
        url = "http://api.eksigator.com/demo/demo/getList"
        http.fetch(url, callback=self.async_callback(self.on_response))


      def on_response(self, response):
        items = tornado.escape.json_decode(response.body)
        for item in items:
           self.write( item["title"] + "<br/>" )


        # this will end async requst
        self.finish()
...

                http://github.com/yuxel/snippets/blob/master/python/tornado/async.py
| database
import tornado.database
...


class DBHandler(tornado.web.RequestHandler):
      def get(self):
        db = tornado.database.Connection(
           host="localhost", database="pyist",
           user="root", password="12345678")


        datas = db.query("select name_surname from pyist")


        # print datas
        for data in datas:
           self.write(data["name_surname"])
           self.write("<br/>")
...

             http://github.com/yuxel/snippets/blob/master/python/tornado/database.py
...
                                           | static dosyalar
application = tornado.web.Application([
      (r"/", MainHandler),
], static_path = os.path.join(os.path.dirname(__file__), "static"))


...



{{ static_url(“hello.txt”) }}
         http://github.com/yuxel/snippets/blob/master/python/tornado/translation.py
| chat demo
 Chat demosunu sadeleştirilmiş hali




http://github.com/yuxel/snippets/blob/master/python/tornado/chat/
| proje

http://github.com/yuxel/feedget
  http://feedget.net/ (alpha)
| kaynaklar

   http://www.tornadoweb.org/
http://github.com/facebook/tornado
   irc://irc.freenode.net/tornado
| iletişim
      Osman Yüksel

yuxel |ET| sonsuzdongu {DAT} com
         http://yuxel.net

More Related Content

What's hot

服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScriptQiangning Hong
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiJérémy Derussé
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launchedMat Schaffer
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsSolution4Future
 
Multithreading on iOS
Multithreading on iOSMultithreading on iOS
Multithreading on iOSMake School
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2Elizabeth Smith
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleTom Croucher
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Charles Nutter
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsPetr Dvorak
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOSPetr Dvorak
 
Customising Your Own Web Framework In Go
Customising Your Own Web Framework In GoCustomising Your Own Web Framework In Go
Customising Your Own Web Framework In GoJonathan Gomez
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011Charles Nutter
 
Building servers with Node.js
Building servers with Node.jsBuilding servers with Node.js
Building servers with Node.jsConFoo
 
Apache ant
Apache antApache ant
Apache antkoniik
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHPHari K T
 

What's hot (20)

Python, do you even async?
Python, do you even async?Python, do you even async?
Python, do you even async?
 
服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript服务框架: Thrift & PasteScript
服务框架: Thrift & PasteScript
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
Pycon - Python for ethical hackers
Pycon - Python for ethical hackers Pycon - Python for ethical hackers
Pycon - Python for ethical hackers
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
wwc start-launched
wwc start-launchedwwc start-launched
wwc start-launched
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
 
Multithreading on iOS
Multithreading on iOSMultithreading on iOS
Multithreading on iOS
 
Php on the desktop and php gtk2
Php on the desktop and php gtk2Php on the desktop and php gtk2
Php on the desktop and php gtk2
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale
 
Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013Beyond JVM - YOW! Sydney 2013
Beyond JVM - YOW! Sydney 2013
 
MFF UK - Advanced iOS Topics
MFF UK - Advanced iOS TopicsMFF UK - Advanced iOS Topics
MFF UK - Advanced iOS Topics
 
Php go vrooom!
Php go vrooom!Php go vrooom!
Php go vrooom!
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOS
 
Customising Your Own Web Framework In Go
Customising Your Own Web Framework In GoCustomising Your Own Web Framework In Go
Customising Your Own Web Framework In Go
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011
 
Tatsumaki
TatsumakiTatsumaki
Tatsumaki
 
Building servers with Node.js
Building servers with Node.jsBuilding servers with Node.js
Building servers with Node.js
 
Apache ant
Apache antApache ant
Apache ant
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
 

Viewers also liked

An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Introduction to Tornado - TienNA
Introduction to Tornado - TienNAIntroduction to Tornado - TienNA
Introduction to Tornado - TienNAFramgia Vietnam
 
Ö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
 
Real time server
Real time serverReal time server
Real time serverthepian
 
What is a tornado?
What is a tornado?What is a tornado?
What is a tornado?Austin
 
Contoh Lembar Catatan Fakta Guru
Contoh Lembar Catatan Fakta GuruContoh Lembar Catatan Fakta Guru
Contoh Lembar Catatan Fakta Guruenesha sie
 
Web backends development using Python
Web backends development using PythonWeb backends development using Python
Web backends development using PythonAyun Park
 

Viewers also liked (9)

An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Tornado
TornadoTornado
Tornado
 
Tornado
TornadoTornado
Tornado
 
Introduction to Tornado - TienNA
Introduction to Tornado - TienNAIntroduction to Tornado - TienNA
Introduction to Tornado - TienNA
 
Ö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...
 
Real time server
Real time serverReal time server
Real time server
 
What is a tornado?
What is a tornado?What is a tornado?
What is a tornado?
 
Contoh Lembar Catatan Fakta Guru
Contoh Lembar Catatan Fakta GuruContoh Lembar Catatan Fakta Guru
Contoh Lembar Catatan Fakta Guru
 
Web backends development using Python
Web backends development using PythonWeb backends development using Python
Web backends development using Python
 

Similar to Tornadoweb

GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 
Twig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPTwig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPFabien Potencier
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJSSylvain Zimmer
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsAlex Eftimie
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 
Hands on django part 1
Hands on django part 1Hands on django part 1
Hands on django part 1MicroPyramid .
 
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 ライブコーディングscalaconfjp
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Ngoc Dao
 
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 middlewareAlona Mekhovova
 
Nginx + Tornado = 17k req/s
Nginx + Tornado = 17k req/sNginx + Tornado = 17k req/s
Nginx + Tornado = 17k req/smoret1979
 
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)Mark Hamstra
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPressWalter Ebert
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Mark Hamstra
 

Similar to Tornadoweb (20)

GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Twig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHPTwig, the flexible, fast, and secure template language for PHP
Twig, the flexible, fast, and secure template language for PHP
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Web Crawling with NodeJS
Web Crawling with NodeJSWeb Crawling with NodeJS
Web Crawling with NodeJS
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshops
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
Hands on django part 1
Hands on django part 1Hands on django part 1
Hands on django part 1
 
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
 
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
 
Nginx + Tornado = 17k req/s
Nginx + Tornado = 17k req/sNginx + Tornado = 17k req/s
Nginx + Tornado = 17k req/s
 
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
Unleashing Creative Freedom with MODX (2015-09-08 at PHPAmersfoort)
 
Drupal vs WordPress
Drupal vs WordPressDrupal vs WordPress
Drupal vs WordPress
 
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
Unleashing Creative Freedom with MODX (2015-07-21 @ PHP FRL)
 

More from Osman Yuksel

More from Osman Yuksel (8)

Jenkins
JenkinsJenkins
Jenkins
 
PHPUnit ve Laravel
PHPUnit ve LaravelPHPUnit ve Laravel
PHPUnit ve Laravel
 
Varnish
VarnishVarnish
Varnish
 
Muhafiz
MuhafizMuhafiz
Muhafiz
 
Selenium
SeleniumSelenium
Selenium
 
Jasminebdd
JasminebddJasminebdd
Jasminebdd
 
Web Onyuzu Nasil Olmali
Web Onyuzu Nasil OlmaliWeb Onyuzu Nasil Olmali
Web Onyuzu Nasil Olmali
 
JavaScript sunumu
JavaScript sunumuJavaScript sunumu
JavaScript sunumu
 

Recently uploaded

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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
[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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

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...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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...
 
[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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Tornadoweb

  • 1.
  • 2. Tornado, Friendfeed'in kullandığı non-blocking (bkz:non blocking) ve ölçeklenebilir web araçlarının adıdır. ● Facebook, Friendfeed'i satın aldıktan Apache lisansı ile açık kaynak olarak dağıtılmaya başlandı.
  • 3. | Kurulum wget -c http://github.com/downloads/facebook/tornado/tornado-1.0.tar.gz tar xvzf tornado-1.0.tar.gz cd tornado-1.0 python setup.py build sudo python setup.py install Veya apt-get install pyton-tornado (debian sid)
  • 4. | Performans ● 'Hello world' performansı
  • 5. | Modüller High Level Modüller Low level modüller ● web ● httpserver ● escape ● iostream ● database ● İoloop ● template ● httpclient ● auth ● locale ● epoll ● options
  • 6. | web Friendfeed'in üzerine kurulduğu, başlıca ana parçaları içeren modül
  • 7. | escape XHTML, JSON ve URL encode/decode işlemleri için modüller
  • 8. | database MySQLdb modülü üzerine geliştirilmiş bir wrapper
  • 10. | auth 3. parti kimlik doğrulama kütüphaneleri (Google OpenID/OAuth, Facebook Platform, Yahoo BBAuth, FriendFeed OpenID/OAuth, Twitter OAuth)
  • 12. | options Komut satırından veya yapılandırma dosyasından yapılandırma almak için modül (optparser)
  • 13. | low level Bunların altında ise esas non-blocking işlemleri yapan ● httpserver : non-blocking http sunucu ● iostream : non-blocking socketleri okumak için geliştirilmiş bir modül ● ioloop : ana i/o modülü ● Bir de amazon s3 simüle eden bir sunucu modülü var.
  • 15. #!/usr/bin/python | hello world import tornado.httpserver import tornado.ioloop import tornado.web class HelloHandler(tornado.web.RequestHandler): def get(self): self.write("Hello World") application = tornado.web.Application([ (r"/", HelloHandler), ]) if __name__ == "__main__": http_server = tornado.httpserver.HTTPServer(application) http_server.listen(8888) tornado.ioloop.IOLoop.instance().start() http://github.com/yuxel/snippets/blob/master/python/tornado/helloWorld.py
  • 16. ..... | request handling # handles pages matches URI /another/someUriParam class AnotherHandler(tornado.web.RequestHandler): def get(self,uriParam): self.write("This is another page with URI parameter = " + uriParam) application = tornado.web.Application([ (r"/another/([^/]+)", AnotherHandler), ]) .... http://github.com/yuxel/snippets/blob/master/python/tornado/requestHandling.py
  • 17. ... | request handling # handles pages matches /postTest/ and demonstrate getting request parameter class PostSomethingHandler(tornado.web.RequestHandler): def get(self): form = """<form method="post"> <input type="text" name="something"/> <input type="submit"/> </form>""" self.write(form) def post(self): postedValue = self.get_argument("something") # get request argument self.write("You've postted 'something' as : " + postedValue) application = tornado.web.Application([ (r"/postTest/", PostSomethingHandler), ]) ... http://github.com/yuxel/snippets/blob/master/python/tornado/requestHandling.py
  • 18. ... | request handling # demonstrates an HTTP response error class ResponseErrorHandler(tornado.web.RequestHandler): def get(self): # send a 403 forbidden error raise tornado.web.HTTPError(403) application = tornado.web.Application([ (r"/someError/", ResponseErrorHandler), ]) ... http://github.com/yuxel/snippets/blob/master/python/tornado/requestHandling.py
  • 19. ... | cookie # demonstrates cookie usage class MainHandler(tornado.web.RequestHandler): def get(self): cookieName = "pyist"; cookieValue = self.get_cookie(cookieName) currentTimestamp = str(time.time()) if not cookieValue: self.set_cookie(cookieName, currentTimestamp) self.write("I've just set your cookie, refresh!") else: self.write("Cookie value : " + cookieValue) ... http://github.com/yuxel/snippets/blob/master/python/tornado/cookie.py
  • 20. ... | secure cookie # demonstrates secure cookie example class SecureCookieHandler(tornado.web.RequestHandler): def get(self): cookieName = "pyist_secure"; cookieValue = self.get_secure_cookie(cookieName) currentTimestamp = str(time.time()) if not cookieValue: self.set_secure_cookie(cookieName, currentTimestamp) self.write("I've just set your cookie, refresh!") else: self.write("Cookie value : " + cookieValue) ... http://github.com/yuxel/snippets/blob/master/python/tornado/cookie.py
  • 21. ... <!DOCTYPE html> | template <html> <head> <title>{{ title }}</title> <meta charset="utf-8" /> </head> <body> {% if userLogged %} Hi {{ userLogged }} {% else %} You need to log in to see this page {% end %} </body> </html> ... http://github.com/yuxel/snippets/blob/master/python/tornado/templates/main.html
  • 22. ... | template # handles main page class MainHandler(tornado.web.RequestHandler): def get(self): #we demonstrate this using a ?userLogged=userName parameter switchLoggedFromGet = self.get_argument("userLogged", False) #remove html entities switchLoggedFromGet = tornado.escape.xhtml_escape(switchLoggedFromGet) self.render("templates/main.html", title="Pyist.net", userLogged=switchLoggedFromGet) ... http://github.com/yuxel/snippets/blob/master/python/tornado/template.py
  • 23. ... | locale class TRHandler(tornado.web.RequestHandler): def get(self): tornado.locale.set_default_locale('tr_TR') self.render("templates/translation.html") # English page class ENHandler(tornado.web.RequestHandler): def get(self): tornado.locale.set_default_locale('en_US') self.render("templates/translation.html") ... if __name__ == "__main__": #set path for location dir translationsPath = os.path.join(os.path.dirname(__file__), "translations") tornado.locale.load_translations(translationsPath) ... http://github.com/yuxel/snippets/blob/master/python/tornado/translation.py
  • 24. tr_TR.csv | locale "Hello World!","Merhaba dunya!" "This is another test","Bu bir test" en_EN.csv "Hello World!","Hello, world!" "This is another test","This is another test" http://github.com/yuxel/snippets/blob/master/python/tornado/translations
  • 25. ... | xsrf koruması # handles main page class MainHandler(tornado.web.RequestHandler): def get(self): self.render("templates/xsrf.html") # if _xsrf value doesnt match xsrf cookie value, this will return 403 def post(self): postedValue = self.get_argument("something") # get request argument self.write("You've postted 'something' as : " + postedValue) application = tornado.web.Application([ (r"/", MainHandler), ], cookie_secret="SomeSecret",xsrf_cookies=True) ... http://github.com/yuxel/snippets/blob/master/python/tornado/xsrf.py
  • 26. | xsrf koruması <!DOCTYPE html> <html> <head> <title>Pyist Tornadoweb</title> <meta charset="utf-8" /> </head> <body> <form action="" method="post"> {{ xsrf_form_html() }} <div> Write something: <input type="text" name="something"/> <input type="submit" value="Try"/> </div> </form> </body> </html> http://github.com/yuxel/snippets/blob/master/python/tornado/templates/xsrf.html
  • 27. import tornado.httpclient | asenkron istekler ... class MainHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self): http = tornado.httpclient.AsyncHTTPClient() url = "http://api.eksigator.com/demo/demo/getList" http.fetch(url, callback=self.async_callback(self.on_response)) def on_response(self, response): items = tornado.escape.json_decode(response.body) for item in items: self.write( item["title"] + "<br/>" ) # this will end async requst self.finish() ... http://github.com/yuxel/snippets/blob/master/python/tornado/async.py
  • 28. | database import tornado.database ... class DBHandler(tornado.web.RequestHandler): def get(self): db = tornado.database.Connection( host="localhost", database="pyist", user="root", password="12345678") datas = db.query("select name_surname from pyist") # print datas for data in datas: self.write(data["name_surname"]) self.write("<br/>") ... http://github.com/yuxel/snippets/blob/master/python/tornado/database.py
  • 29. ... | static dosyalar application = tornado.web.Application([ (r"/", MainHandler), ], static_path = os.path.join(os.path.dirname(__file__), "static")) ... {{ static_url(“hello.txt”) }} http://github.com/yuxel/snippets/blob/master/python/tornado/translation.py
  • 30. | chat demo Chat demosunu sadeleştirilmiş hali http://github.com/yuxel/snippets/blob/master/python/tornado/chat/
  • 31. | proje http://github.com/yuxel/feedget http://feedget.net/ (alpha)
  • 32. | kaynaklar http://www.tornadoweb.org/ http://github.com/facebook/tornado irc://irc.freenode.net/tornado
  • 33. | iletişim Osman Yüksel yuxel |ET| sonsuzdongu {DAT} com http://yuxel.net