本文整理匯總了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()
示例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()
示例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()
示例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()