mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-28 00:25:21 +01:00
by settings index_paths to '$liveweb'. When used, creates a RewriteHandler instead of WBHandler Can also specify 'proxyhostport' to set the live rewrite to go through a proxy fallback: allow fallback to a different handler (usually live rewrite) by specifying 'redir_fallback' with name of handler. Instead of 404, a not found response will internally call the fallback handler to get a response
29 lines
908 B
Python
29 lines
908 B
Python
from pywb.framework.basehandlers import WbUrlHandler
|
|
from pywb.framework.wbrequestresponse import WbResponse
|
|
from pywb.framework.archivalrouter import ArchivalRouter, Route
|
|
|
|
from handlers import StaticHandler
|
|
|
|
from replay_views import RewriteLiveView
|
|
|
|
|
|
#=================================================================
|
|
class RewriteHandler(WbUrlHandler):
|
|
def __init__(self, config):
|
|
self.rewrite_view = RewriteLiveView(config)
|
|
|
|
def __call__(self, wbrequest):
|
|
return self.rewrite_view(wbrequest)
|
|
|
|
def __str__(self):
|
|
return 'Live Web Rewrite Handler'
|
|
|
|
|
|
#=================================================================
|
|
def create_live_rewriter_app(config={}):
|
|
routes = [Route('rewrite', RewriteHandler(config)),
|
|
Route('static/default', StaticHandler('pywb/static/'))
|
|
]
|
|
|
|
return ArchivalRouter(routes, hostpaths=['http://localhost:8080'])
|