Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: improve wayback cli to take optional port, threads and working d…
…ir arguments switch to waitress as default WSGI server instead of wsgiref
- Loading branch information
Showing
6 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
*.arc -text | ||
*.warc -text | ||
*.idx -text | ||
*.idxj -text | ||
*.cdx -text | ||
*.cdxj -text | ||
*.gz -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#================================================================= | ||
def wayback(args=None): | ||
from argparse import ArgumentParser, RawTextHelpFormatter | ||
|
||
parser = ArgumentParser('pywb Wayback Web Archive Replay') | ||
parser.add_argument('-p', '--port', type=int, default=8080) | ||
parser.add_argument('-t', '--threads', type=int, default=4) | ||
|
||
help_dir='Specify root archive dir (default is current working directory)' | ||
parser.add_argument('-d', '--directory', help=help_dir) | ||
|
||
r = parser.parse_args(args) | ||
if r.directory: #pragma: no cover | ||
import os | ||
os.chdir(r.directory) | ||
|
||
# Load App | ||
from pywb.apps.wayback import application | ||
|
||
try: | ||
from waitress import serve | ||
serve(application, port=r.port, threads=r.threads) | ||
except ImportError: # pragma: no cover | ||
# Shouldn't ever happen as installing waitress, but just in case.. | ||
from pywb.framework.wsgi_wrappers import start_wsgi_server | ||
start_wsgi_server(application, 'Wayback', default_port=r.port) | ||
|
||
|
||
#================================================================= | ||
if __name__ == "__main__": | ||
wayback() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,8 @@ | ||
from pywb.framework.wsgi_wrappers import init_app, start_wsgi_server | ||
from pywb.framework.wsgi_wrappers import init_app | ||
from pywb.webapp.pywb_init import create_wb_router | ||
|
||
|
||
#================================================================= | ||
# init pywb app | ||
#================================================================= | ||
application = init_app(create_wb_router, load_yaml=True) | ||
|
||
|
||
def main(): # pragma: no cover | ||
start_wsgi_server(application, 'Wayback') | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters