__init__.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:djaio 作者: Sberned 项目源码 文件源码
def run(self):
        try:
            subcommand = self.argv[1]
        except IndexError:
            subcommand = 'help'

        if subcommand == 'runserver':
            try:
                host, port = self.argv[2].split(':')
                port = int(port)
                if not port:
                    port = 8080
            except (IndexError, ValueError):
                print('WARNING! Incorrect host:port - using default settings.')
                host = '0.0.0.0'
                port = 8080
            web.run_app(self.app, host=host, port=port, loop=self.app.loop)
        elif subcommand == 'routes':
            from djaio.ext.routes import print_routes
            print_routes(self.app)

        elif subcommand == 'help':
            print('=' * 60)
            print('Usage: {} <command> <options>'.format(self.argv[0].rsplit('/', 1)[-1]))
            print('Available commands:')
            print(' * help - shows this message')
            print(' * runserver host:port - runs web server')
            for key, comm_obj in self.app.commands.items():
                print(' * {} <options> - {}'.format(key, comm_obj.get('description')))
            print('=' * 60)
        elif subcommand == 'shell':
            import IPython
            IPython.start_ipython(argv=[])

        elif subcommand in self.app.commands:
            _args = self.argv[2:]
            _coro = self.app.commands[subcommand].get('func')
            self.app.loop.run_until_complete(_coro(self.app, *_args))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号