本文整理汇总了Python中pywb.framework.wsgi_wrappers.init_app函数的典型用法代码示例。如果您正苦于以下问题:Python init_app函数的具体用法?Python init_app怎么用?Python init_app使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init_app函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
def load(self):
config = dict(proxyhostport=self.r.proxy,
framed_replay='inverse' if self.r.framed else False,
enable_auto_colls=False,
collections={'live': '$liveweb'})
return init_app(create_wb_router, load_yaml=False, config=config)
示例2: __init__
def __init__(self, archivefiles):
self.archivefiles = archivefiles
self.coll_name = ''
self.cdx_file = tempfile.NamedTemporaryFile(delete=False,
suffix='.cdxj',
prefix='cdx')
self.path_index = tempfile.NamedTemporaryFile(delete=False,
suffix='.txt')
try:
pagelist = self.update_cdx(self.cdx_file, archivefiles)
except Exception as e:
msg = "WebArchivePlayer is unable to read the input file(s) and will quit.\n\nDetails: " + str(e)[:255]
if no_wx:
sys.stderr.write(msg + '\n')
else:
dlg = wx.MessageDialog(None, msg, "Error Reading Web Archive File(s)", style=wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
sys.exit(1)
config = self._load_dynamic_config()
config['_pagelist'] = pagelist
config['_archivefiles'] = archivefiles
self.write_path_index()
self.application = init_app(create_wb_router,
load_yaml=False,
config=config)
示例3: setup_module
def setup_module():
global requestlog
requestlog = []
def make_httpd(app):
global proxyserv
proxyserv = ProxyServer(('', 0), ProxyRequest)
proxyserv.requestlog = requestlog
proxyserv.force_err = False
return proxyserv
global server
server = ServerThreadRunner(make_httpd)
config = dict(collections=dict(rewrite='$liveweb'),
framed_replay=True,
proxyhostport=server.proxy_dict)
global cache
cache = {}
def create_cache():
return cache
pywb.webapp.live_rewrite_handler.create_cache = create_cache
global app
app = init_app(create_wb_router,
load_yaml=False,
config=config)
global testapp
testapp = webtest.TestApp(app)
示例4: test_err_app
def test_err_app():
the_app = init_app(initer(TestErrApp), load_yaml=False)
testapp = webtest.TestApp(the_app)
resp = testapp.get('/abc', expect_errors=True)
assert resp.status_int == 400
assert '400 Bad Request Error: Test Error' in resp.body
示例5: test_ok_app
def test_ok_app():
the_app = init_app(initer(TestOkApp), load_yaml=False)
testapp = webtest.TestApp(the_app)
resp = testapp.get('/')
assert resp.status_int == 200
assert 'Test' in resp.body
示例6: make_app
def make_app(config_file, pywb_router=create_wb_router):
app = init_app(pywb_router,
load_yaml=True,
config_file=config_file)
testapp = TestApp(app)
return app, testapp
示例7: test_custom_err_app
def test_custom_err_app():
the_app = init_app(initer(TestCustomErrApp), load_yaml=False)
testapp = webtest.TestApp(the_app)
resp = testapp.get('/abc', expect_errors=True)
assert resp.status_int == 403
assert '403 Access Denied Error: Forbidden Test' in resp.body
示例8: test_err_app
def test_err_app():
the_app = init_app(initer(TestErrApp), load_yaml=False)
testapp = webtest.TestApp(the_app)
resp = testapp.get('/abc', expect_errors=True)
assert resp.status_int == 500
assert '500 Internal Server Error Error: Test Unexpected Error' in resp.body
示例9: setup
def setup(self):
#self.app = pywb.wbapp.create_wb_app(pywb.pywb_init.pywb_config())
# save it in self - useful for debugging
self.app = init_app(create_wb_router,
load_yaml=True,
config_file=self.TEST_CONFIG)
#self.router = pywb_config(self.TEST_CONFIG)
#self.app = create_wb_app(self.router)
self.testapp = webtest.TestApp(self.app)
示例10: __init__
def __init__(self, *args, **kwargs):
super(ServeThread, self).__init__(*args, **kwargs)
self.app = init_app(create_wb_router,
load_yaml=True,
config_file=TEST_CONFIG)
# init with port 0 to allow os to pick a port
self.httpd = make_server('', 0, self.app)
port = self.httpd.socket.getsockname()[1]
proxy_str = 'http://localhost:' + str(port)
self.proxy_dict = {'http': proxy_str}
示例11: make_app
def make_app(config_file, pywb_router=create_wb_router):
app = init_app(pywb_router, load_yaml=True, config_file=config_file)
testapp = TestApp(app)
class Resp(TestResponse):
def __init__(self, *args, **kwargs):
super(Resp, self).__init__(*args, **kwargs)
if self.headers.get("Content-Type"):
self.charset = "utf-8"
TestApp.RequestClass.ResponseClass = Resp
return app, testapp
示例12: create_app
def create_app():
parser = ArgumentParser(description='Live Rewrite Server')
parser.add_argument('-x', '--proxy',
action='store',
help='Specify host:port to use as HTTP/S proxy')
result, unknown = parser.parse_known_args()
config = dict(proxyhostport=result.proxy, framed_replay=True)
app = init_app(create_live_rewriter_app, load_yaml=False,
config=config)
return app
示例13: __init__
def __init__(self, make_httpd, config_file=None):
if config_file:
self.app = init_app(create_wb_router,
load_yaml=True,
config_file=config_file)
else:
self.app = None
self.httpd = make_httpd(self.app)
self.port = self.httpd.socket.getsockname()[1]
proxy_str = 'http://localhost:' + str(self.port)
self.proxy_dict = {'http': proxy_str,
'https': proxy_str}
def run():
self.httpd.serve_forever()
self.thread = threading.Thread(target=run)
self.thread.daemon = True
self.thread.start()
示例14: __init__
def __init__(self, archivefiles):
self.archivefiles = archivefiles
self.coll_name = ''
self.cdx_file = tempfile.NamedTemporaryFile(delete=False,
suffix='.cdxj',
prefix='cdx')
self.path_index = tempfile.NamedTemporaryFile(delete=False,
suffix='.txt')
pagelist = self.update_cdx(self.cdx_file, archivefiles)
config = self._load_config()
config['_pagelist'] = pagelist
config['_archivefiles'] = archivefiles
self.write_path_index()
self.application = init_app(create_wb_router,
load_yaml=False,
config=config)
示例15: setup
def setup(self):
self.requestlog = []
self.cache = {}
def make_httpd(app):
proxyserv = ProxyServer(("", 0), ProxyRequest)
proxyserv.requestlog = self.requestlog
proxyserv.force_err = False
self.proxyserv = proxyserv
return proxyserv
self.server = ServerThreadRunner(make_httpd)
config = dict(collections=dict(rewrite="$liveweb"), framed_replay=True, proxyhostport=self.server.proxy_dict)
self.app = init_app(create_wb_router, load_yaml=False, config=config)
def create_cache():
return self.cache
pywb.webapp.live_rewrite_handler.create_cache = create_cache
self.testapp = webtest.TestApp(self.app)