2013-03-28 04:11:06 +00:00
|
|
|
Tornado Web Server
|
|
|
|
==================
|
|
|
|
|
2015-10-07 03:03:58 +00:00
|
|
|
.. image:: https://badges.gitter.im/Join%20Chat.svg
|
|
|
|
:alt: Join the chat at https://gitter.im/tornadoweb/tornado
|
|
|
|
:target: https://gitter.im/tornadoweb/tornado?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
|
|
|
|
2013-03-28 04:11:06 +00:00
|
|
|
`Tornado <http://www.tornadoweb.org>`_ is a Python web framework and
|
|
|
|
asynchronous networking library, originally developed at `FriendFeed
|
|
|
|
<http://friendfeed.com>`_. By using non-blocking network I/O, Tornado
|
|
|
|
can scale to tens of thousands of open connections, making it ideal for
|
2016-03-13 16:59:17 +00:00
|
|
|
`long polling <http://en.wikipedia.org/wiki/Push_technology#Long_Polling>`_,
|
2013-03-28 04:11:06 +00:00
|
|
|
`WebSockets <http://en.wikipedia.org/wiki/WebSocket>`_, and other
|
|
|
|
applications that require a long-lived connection to each user.
|
|
|
|
|
|
|
|
Hello, world
|
|
|
|
------------
|
|
|
|
|
2015-01-30 10:47:16 +00:00
|
|
|
Here is a simple "Hello, world" example web app for Tornado:
|
2015-10-24 23:07:59 +00:00
|
|
|
|
2015-01-30 10:47:16 +00:00
|
|
|
.. code-block:: python
|
2013-03-28 04:11:06 +00:00
|
|
|
|
|
|
|
import tornado.ioloop
|
|
|
|
import tornado.web
|
|
|
|
|
|
|
|
class MainHandler(tornado.web.RequestHandler):
|
|
|
|
def get(self):
|
|
|
|
self.write("Hello, world")
|
|
|
|
|
2015-06-21 14:04:21 +00:00
|
|
|
def make_app():
|
|
|
|
return tornado.web.Application([
|
|
|
|
(r"/", MainHandler),
|
|
|
|
])
|
2013-03-28 04:11:06 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2015-06-21 14:04:21 +00:00
|
|
|
app = make_app()
|
|
|
|
app.listen(8888)
|
|
|
|
tornado.ioloop.IOLoop.current().start()
|
2013-03-28 04:11:06 +00:00
|
|
|
|
|
|
|
This example does not use any of Tornado's asynchronous features; for
|
|
|
|
that see this `simple chat room
|
2014-05-17 14:19:17 +00:00
|
|
|
<https://github.com/tornadoweb/tornado/tree/stable/demos/chat>`_.
|
2013-03-28 04:11:06 +00:00
|
|
|
|
2015-10-24 23:07:59 +00:00
|
|
|
Documentation
|
|
|
|
-------------
|
2013-03-28 04:11:06 +00:00
|
|
|
|
2015-10-24 23:07:59 +00:00
|
|
|
Documentation and links to additional resources are available at
|
|
|
|
http://www.tornadoweb.org
|