Mercurial > cgi-bin > hgweb.cgi > tincan
comparison launch @ 40:df27cf08c093 draft
Add support for serving static files.
author | David Barts <n5jrn@me.com> |
---|---|
date | Wed, 29 May 2019 09:40:32 -0700 |
parents | ce67eac10fc7 |
children | 997d0c8c174f |
comparison
equal
deleted
inserted
replaced
39:ee19984ba31d | 40:df27cf08c093 |
---|---|
20 opt("-b", "--bind", default="localhost", help="address to bind to (default: localhost)") | 20 opt("-b", "--bind", default="localhost", help="address to bind to (default: localhost)") |
21 opt("-d", "--debug", action="store_true", help="enable debug mode") | 21 opt("-d", "--debug", action="store_true", help="enable debug mode") |
22 opt("-e", "--encoding", default=ENCODING, help="encoding to use (default {0})".format(ENCODING)) | 22 opt("-e", "--encoding", default=ENCODING, help="encoding to use (default {0})".format(ENCODING)) |
23 opt("-f", "--force", action="store_true", help="do not abort on errors") | 23 opt("-f", "--force", action="store_true", help="do not abort on errors") |
24 opt("-p", "--port", default=8080, help="port to listen on (default: 8080)") | 24 opt("-p", "--port", default=8080, help="port to listen on (default: 8080)") |
25 opt("-s", "--static", action="store_true", help="serve static files") | |
25 opt("directory", default=".", help="directory to serve", nargs='?') | 26 opt("directory", default=".", help="directory to serve", nargs='?') |
26 opt("path", default="/", help="URL path to serve", nargs='?') | 27 opt("path", default="/", help="URL path to serve", nargs='?') |
27 args = parser.parse_args(sys.argv[1:]) | 28 args = parser.parse_args(sys.argv[1:]) |
28 app, errors = launch(fsroot=args.directory, urlroot=args.path, debug=args.debug, | 29 app, errors = launch(fsroot=args.directory, urlroot=args.path, debug=args.debug, |
29 encoding=args.encoding) | 30 encoding=args.encoding, static=args.static) |
30 if errors: | 31 if errors: |
31 action = "continuing" if args.force else "aborting" | 32 action = "continuing" if args.force else "aborting" |
32 sys.stderr.write("{0}: {1} error{2} detected, {3}\n".format( | 33 sys.stderr.write("{0}: {1} error{2} detected, {3}\n".format( |
33 MYNAME, errors, "" if errors == 1 else "s", action)) | 34 MYNAME, errors, "" if errors == 1 else "s", action)) |
34 if not args.force: sys.exit(1) | 35 if not args.force: sys.exit(1) |