当前位置: 首页>>代码示例>>Python>>正文


Python bottle.install方法代码示例

本文整理汇总了Python中bottle.install方法的典型用法代码示例。如果您正苦于以下问题:Python bottle.install方法的具体用法?Python bottle.install怎么用?Python bottle.install使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bottle的用法示例。


在下文中一共展示了bottle.install方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import install [as 别名]
def main(argv, cfg):
	global authdict, allow_passwordless, db

	parser = ArgumentParser(prog=argv.pop(0) + ' urd')
	parser.add_argument('--path', type=str, default='urd.db',
		help='database directory (can be relative to project directory) (default: urd.db)',
	)
	parser.add_argument('--allow-passwordless', action='store_true', help='accept any pass for users not in passwd.')
	parser.add_argument('--quiet', action='store_true', help='less chatty.')
	args = parser.parse_args(argv)
	if not args.quiet:
		print('-'*79)
		print(args)
		print()

	auth_fn = os.path.join(args.path, 'passwd')
	authdict = readauth(auth_fn)
	allow_passwordless = args.allow_passwordless
	if not authdict and not args.allow_passwordless:
		raise Exception('No users in %r and --allow-passwordless not specified.' % (auth_fn,))
	db = DB(args.path, not args.quiet)

	bottle.install(jsonify)

	kw = dict(debug=False, reloader=False, quiet=args.quiet)
	listen = cfg.urd_listen
	if isinstance(listen, tuple):
		kw['host'], kw['port'] = listen
	else:
		from accelerator.unixhttp import WSGIUnixServer, WSGIUnixRequestHandler
		from accelerator.server import check_socket
		if listen == 'local':
			listen = '.socket.dir/urd'
		check_socket(listen)
		kw['server_class'] = WSGIUnixServer
		kw['handler_class'] = WSGIUnixRequestHandler
		kw['host'] = listen
		kw['port'] = 0
	bottle.run(**kw) 
开发者ID:eBay,项目名称:accelerator,代码行数:41,代码来源:urd.py

示例2: run_proxy

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import install [as 别名]
def run_proxy(args):

    #
    # ERROR HANDLERS
    #
    @error(401)
    def error404(error):
        return template(error_tpl, headline='Error '+error.status, error=error.body)

    @error(500)
    def error500(error):
        return template(error_tpl, headline='Error '+error.status, error=error.body)

    #
    # SPECIAL ENDPOINTS
    #
    @route('/health')
    def hello():
        return template(healthcheck_tpl, headline='Healthcheck')

    @route('/install-success')
    def hello():
        remote_page_call_status_code = proxy_trough_helper('https://{0}.github.io/{1}/{2}/{3}'.format(args.owner, args.repository, args.obfuscator, '/')).status_code
        return template(install_success_tpl, headline='Installation Success', remote_page_call_status_code=remote_page_call_status_code)

    #
    # make args available in auth callback
    #
    global owner, auth_type
    owner = args.owner
    auth_type = args.authType

    @route('/<url:re:.+>')
    @auth_basic(check_pass)
    def proxy_trough(url):
        return proxy_trough_helper('https://{0}.github.io/{1}/{2}/{3}'.format(args.owner, args.repository, args.obfuscator, normalize_proxy_url(url)))

    @route('/')
    @auth_basic(check_pass)
    def proxy_trough_root_page():
        return proxy_trough_helper('https://{0}.github.io/{1}/{2}/{3}'.format(args.owner, args.repository, args.obfuscator, '/index.html'))

    #
    # RUN BY ENVIRONMENT
    #
    if args.environment == 'wsgi':
        run(host='localhost', port=args.port, debug=True)
    if args.environment == 'heroku':
        run(host="0.0.0.0", port=int(args.port))
    else:
        run(server='cgi') 
开发者ID:comsysto,项目名称:github-pages-basic-auth-proxy,代码行数:53,代码来源:proxy.py


注:本文中的bottle.install方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。