SlideShare ist ein Scribd-Unternehmen logo
1 von 33
Downloaden Sie, um offline zu lesen
●   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

Weitere ähnliche Inhalte

Was ist angesagt?

服务框架: 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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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)
 

Mehr von Osman Yuksel

Mehr von 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
 

Kürzlich hochgeladen

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
[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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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 WorkerThousandEyes
 

Kürzlich hochgeladen (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
[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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 

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