码迷,mamicode.com
首页 > 其他好文 > 详细

bottle框架学习(1):命令行

时间:2017-06-15 20:38:37      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:file   ott   rgs   store   mon   ref   art   com   show   

在最初的一段代码,内容如下;

if __name__ == __main__:
    from optparse import OptionParser
    _cmd_parser = OptionParser(usage="usage: %prog [options] package.module:app")
    _opt = _cmd_parser.add_option
    _opt("--version", action="store_true", help="show version number.")
    _opt("-b", "--bind", metavar="ADDRESS", help="bind socket to ADDRESS.")
    _opt("-s", "--server", default=wsgiref, help="use SERVER as backend.")
    _opt("-p", "--plugin", action="append", help="install additional plugin/s.")
    _opt("--debug", action="store_true", help="start server in debug mode.")
    _opt("--reload", action="store_true", help="auto-reload on file changes.")
    _cmd_options, _cmd_args = _cmd_parser.parse_args()
    if _cmd_options.server and _cmd_options.server.startswith(gevent):
        import gevent.monkey; gevent.monkey.patch_all()

 

这里,实际上使用到了OptionParser模块,

出来的提示是:

技术分享

 

bottle框架学习(1):命令行

标签:file   ott   rgs   store   mon   ref   art   com   show   

原文地址:http://www.cnblogs.com/aomi/p/7019577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!