當前位置: 首頁>>代碼示例>>Python>>正文


Python wsgiapp.WSGIApplication方法代碼示例

本文整理匯總了Python中gunicorn.app.wsgiapp.WSGIApplication方法的典型用法代碼示例。如果您正苦於以下問題:Python wsgiapp.WSGIApplication方法的具體用法?Python wsgiapp.WSGIApplication怎麽用?Python wsgiapp.WSGIApplication使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gunicorn.app.wsgiapp的用法示例。


在下文中一共展示了wsgiapp.WSGIApplication方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: gunicorn_run

# 需要導入模塊: from gunicorn.app import wsgiapp [as 別名]
# 或者: from gunicorn.app.wsgiapp import WSGIApplication [as 別名]
def gunicorn_run():
    """
    The ``gunicorn_pecan`` command for launching ``pecan`` applications
    """
    try:
        from gunicorn.app.wsgiapp import WSGIApplication
    except ImportError as exc:
        args = exc.args
        arg0 = args[0] if args else ''
        arg0 += ' (are you sure `gunicorn` is installed?)'
        exc.args = (arg0,) + args[1:]
        raise

    class PecanApplication(WSGIApplication):

        def init(self, parser, opts, args):
            if len(args) != 1:
                parser.error("No configuration file was specified.")

            self.cfgfname = os.path.normpath(
                os.path.join(os.getcwd(), args[0])
            )
            self.cfgfname = os.path.abspath(self.cfgfname)
            if not os.path.exists(self.cfgfname):
                parser.error("Config file not found: %s" % self.cfgfname)

            from pecan.configuration import _runtime_conf, set_config
            set_config(self.cfgfname, overwrite=True)

            # If available, use the host and port from the pecan config file
            cfg = {}
            if _runtime_conf.get('server'):
                server = _runtime_conf['server']
                if hasattr(server, 'host') and hasattr(server, 'port'):
                    cfg['bind'] = '%s:%s' % (
                        server.host, server.port
                    )
            return cfg

        def load(self):
            from pecan.deploy import deploy
            return deploy(self.cfgfname)

    PecanApplication("%(prog)s [OPTIONS] config.py").run() 
開發者ID:openstack,項目名稱:deb-python-pecan,代碼行數:46,代碼來源:serve.py

示例2: run

# 需要導入模塊: from gunicorn.app import wsgiapp [as 別名]
# 或者: from gunicorn.app.wsgiapp import WSGIApplication [as 別名]
def run(self, *args, **kwargs):
        from gunicorn.app.wsgiapp import WSGIApplication

        app = WSGIApplication()

        app.app_uri = 'aardvark:create_app()'
        return app.run() 
開發者ID:Netflix-Skunkworks,項目名稱:aardvark,代碼行數:9,代碼來源:manage.py

示例3: run_wsgi_app

# 需要導入模塊: from gunicorn.app import wsgiapp [as 別名]
# 或者: from gunicorn.app.wsgiapp import WSGIApplication [as 別名]
def run_wsgi_app(address, app):
    try:
        from gunicorn.app.wsgiapp import WSGIApplication
        class GunicornApplication(WSGIApplication):
            def init(self, parser, opts, args):
                return {'bind': '%s:%d' % (address[0], int(address[1])),
                        'workers': 2,
                        'worker_class': 'gevent'}
            def load(self):
                return application
        GunicornApplication().run()
    except ImportError:
        from gevent.wsgi import WSGIServer
        WSGIServer(address, app).serve_forever() 
開發者ID:yuxiaokui,項目名稱:Intranet-Penetration,代碼行數:16,代碼來源:index.py

示例4: run

# 需要導入模塊: from gunicorn.app import wsgiapp [as 別名]
# 或者: from gunicorn.app.wsgiapp import WSGIApplication [as 別名]
def run():
    """\
    The ``gunicorn`` command line runner for launching Gunicorn with
    generic WSGI applications.
    """
    from gunicorn.app.wsgiapp import WSGIApplication
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() 
開發者ID:RoseOu,項目名稱:flasky,代碼行數:9,代碼來源:wsgiapp.py


注:本文中的gunicorn.app.wsgiapp.WSGIApplication方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。