您的位置:首页 > 大数据 > 人工智能

Tornado之main文件

2015-09-01 17:32 375 查看
Tornado Web工程main文件结构

#!/urs/bin/python

'docstring'

import xxx

define("port", default=18000, help="run on the given port", type=int)

class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/", Handler),
]
settings = dict(
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
cookie_secret="61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
)
tornado.web.Application.__init__(self, handlers, **settings)
# application全局设置,如数据库,缓存等
def main():
tornado.options.parse_command_line()
http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()

if __name__ == '__main__':
main()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  tornado python