项目地址:
Blog
简单的tornado服务分支: simple
项目结构

创建对应的文件夹并测试一个最简单的功能

main.py
![]()
1 #!/usr/bin/env python
2 # coding:utf-8
3
4 import tornado.ioloop
5 import tornado.options
6 import tornado.httpserver
7 import tornado.web
8 from tornado.options import define, options
9
10 from url import url
11 from application import settings
12
13 define("port", default="7777", help="run on the given port", type=int)
14
15
16 class Application(tornado.web.Application):
17
18 def __init__(self):
19 tornado.web.Application.__init__(self, url, **settings)
20
21 if __name__ == '__main__':
22 tornado.options.parse_command_line()
23 http_server = tornado.httpserver.HTTPServer(Application())
24 http_server.listen(options.port)
25 tornado.ioloop.IOLoop.instance().start()
View Code