mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-28 00:25:21 +01:00
update README and comments
This commit is contained in:
parent
1033feb2f8
commit
44f68158a9
43
README.md
43
README.md
@ -63,22 +63,51 @@ and look for warcs at paths:
|
|||||||
`http://warcs.example.com/servewarc/` and
|
`http://warcs.example.com/servewarc/` and
|
||||||
`http://warcs.example.com/anotherpath/`,
|
`http://warcs.example.com/anotherpath/`,
|
||||||
|
|
||||||
one could declare a `createWB()` method as follows:
|
one could declare a sample config as follows:
|
||||||
|
|
||||||
def createWB():
|
```
|
||||||
|
def sample_wb_settings():
|
||||||
|
import archiveloader
|
||||||
|
import query, indexreader
|
||||||
|
import replay, replay_resolvers
|
||||||
|
from archivalrouter import ArchivalRequestRouter, Route
|
||||||
|
|
||||||
|
|
||||||
|
# Standard loader which supports WARC/ARC files
|
||||||
aloader = archiveloader.ArchiveLoader()
|
aloader = archiveloader.ArchiveLoader()
|
||||||
query = QueryHandler(indexreader.RemoteCDXServer('http://cdx.example.com/cdx'))
|
|
||||||
|
|
||||||
prefixes = [replay.PrefixResolver('http://warcs.example.com/servewarc/'),
|
# Source for cdx source
|
||||||
replay.PrefixResolver('http://warcs.example.com/anotherpath/')]
|
query_h = query.QueryHandler(indexreader.RemoteCDXServer('http://cdx.example.com/cdx'))
|
||||||
|
|
||||||
replay = replay.RewritingReplayHandler(resolvers = prefixes, archiveloader = aloader, headInsert = headInsert)
|
# Loads warcs specified in cdx from these locations
|
||||||
|
prefixes = [replay_resolvers.PrefixResolver('http://warcs.example.com/servewarc/'),
|
||||||
|
replay_resolvers.PrefixResolver('http://warcs.example.com/anotherpath/')]
|
||||||
|
|
||||||
|
# Create rewriting replay handler to rewrite records
|
||||||
|
replayer = replay.RewritingReplayHandler(resolvers = prefixes, archiveloader = aloader, headInsert = default_head_insert)
|
||||||
|
|
||||||
|
# Create Jinja2 based html query renderer
|
||||||
|
htmlquery = query.J2QueryRenderer('./ui/', 'query.html')
|
||||||
|
|
||||||
|
# Handler which combins query, replayer, and html_query
|
||||||
|
wb_handler = replay.WBHandler(query_h, replayer, htmlquery = htmlquery)
|
||||||
|
|
||||||
|
# Finally, create wb router
|
||||||
return ArchivalRequestRouter(
|
return ArchivalRequestRouter(
|
||||||
{
|
{
|
||||||
Route('mycoll': replay.WBHandler(query, replay)),
|
Route('echo_req', query.DebugEchoRequest()), # Debug ex: just echo parsed request
|
||||||
|
Route('mycoll', wb_handler)
|
||||||
},
|
},
|
||||||
|
# Specify hostnames that pywb will be running on
|
||||||
|
# This will help catch occasionally missed rewrites that fall-through to the host
|
||||||
|
# (See archivalrouter.ReferRedirect)
|
||||||
hostpaths = ['http://mywb.example.com:8080/'])
|
hostpaths = ['http://mywb.example.com:8080/'])
|
||||||
|
```
|
||||||
|
|
||||||
|
The final wsgi application is than created by calling:
|
||||||
|
|
||||||
|
|
||||||
|
`application = create_wb_app(sample_wb_settings())`
|
||||||
|
|
||||||
|
|
||||||
Quick File Reference
|
Quick File Reference
|
||||||
|
@ -125,9 +125,11 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
#=================================================================
|
#=================================================================
|
||||||
try:
|
try:
|
||||||
|
# Attempt to load real settings from globalwb module
|
||||||
import globalwb
|
import globalwb
|
||||||
application = create_wb_app(globalwb.create_global_wb(default_head_insert))
|
application = create_wb_app(globalwb.create_global_wb(default_head_insert))
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
|
# Otherwise, start with the sample settings
|
||||||
application = create_wb_app(sample_wb_settings())
|
application = create_wb_app(sample_wb_settings())
|
||||||
#=================================================================
|
#=================================================================
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user