Home >Backend Development >Python Tutorial >Web服务器框架 Tornado简介

Web服务器框架 Tornado简介

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-16 08:43:181296browse

Tornado 跟其他主流的Web服务器框架(主要是Python框架)不同是采用epoll非阻塞IO,响应快速,可处理数千并发连接,特别适用用于实时的Web服务。

高性能web服务器框架Tornado简单实现restful接口及开发实例 http://www.jb51.net/article/52209.htm

要使用它,必须按照以下套件:

1)Python(建议使用Python 2.5 / Python 2.6)

2)Simplejson(建议使用simplejson 2.0.9)

3)cURL(建议使用curl 7.19.7或以上版本)

4)Pycurl(建议使用pycurl 7.16.2.1)

5)Tornado Web Server(这才是主角,版本就照官网上最新的安装吧)

一个最简单的服务:

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
 def get(self):
  self.write("Hello, world")

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

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn