tornado中options的使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/monkeysheep1234/article/details/89402216
from tornado.options import define, options, parse_command_line

# define,定义一些可以在命令行中传递的参数以及;类型
define('port', default=8888, help="run on the given port", type=int)
define('debug', default=True, help="set tornado debug mode", type=bool)
options.parse_command_line()
# 利用配置文件这种方式也行
# options.parse_config_file("conf.cfg")


def make_app():
    return tornado.web.Application([
        (r"/user", UserHandler),
        ……
    ], debug=options.debug)


if __name__ == "__main__":
    app = make_app()
    app.listen(options.port)
    tornado.ioloop.IOLoop.current().start()

通过命令行 指定运行时的端口号

(tornado_xingfu) H:\project\xingfu_tornado>python app.py --port=9999
 

猜你喜欢

转载自blog.csdn.net/monkeysheep1234/article/details/89402216
今日推荐