Tornado (web server)
Python web server and application framework
From Wikipedia, the free encyclopedia
Tornado is a scalable, non-blocking web server and web application framework written in Python.[2] It was developed for use by FriendFeed; the company was acquired by Facebook in 2009 and Tornado was open-sourced soon after.[3]
| Tornado | |
|---|---|
| Original author | FriendFeed |
| Developers | Ben Darnell and FriendFeed engineering team |
| Release | 2009 |
| Stable release | |
| Written in | Python |
| Operating system | Cross-platform |
| Available in | English |
| Type | Web server |
| License | Apache License 2.0 |
| Website | www |
| Repository | github.com/tornadoweb/tornado |
Performance
Tornado is noted for its high performance. Its design enables handling a large number of concurrent connections (i.e., tries to solve the "C10k problem").
Modules
- An asynchronous MongoDB driver called Motor.
- CouchDB drivers called corduroy and trombi.
- Asynchronous driver for PostgreSQL wrapping psycopg called Momoko
Example
The following code shows a simple web application that displays "Hello World!" when visited:[4]
import asyncio
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
def make_app():
return tornado.web.Application([(r"/", MainHandler),])
async def main():
app = make_app()
app.listen(8888)
await asyncio.Event().wait()
if __name__ == "__main__":
asyncio.run(main())