Add bind argument

This commit is contained in:
Milos Buncic 2022-05-20 17:29:20 +02:00
parent 28a1ac1612
commit 1df84b2ad7
2 changed files with 18 additions and 11 deletions

View File

@ -23,16 +23,17 @@ Install using pip:
## Usage
`updog [-d DIRECTORY] [-p PORT] [--password PASSWORD] [--ssl]`
`updog [-d DIRECTORY] [-b ADDRESS] [-p PORT] [--password PASSWORD] [--ssl]`
| Argument | Description |
|-------------------------------------|--------------------------------------------------|
| -d DIRECTORY, --directory DIRECTORY | Root directory [Default=.] |
| -p PORT, --port PORT | Port to serve [Default=9090] |
| --password PASSWORD | Use a password to access the page. (No username) |
| --ssl | Enable transport encryption via SSL |
| --version | Show version |
| -h, --help | Show help |
| Argument | Description |
|-------------------------------------|---------------------------------------------------------|
| -d DIRECTORY, --directory DIRECTORY | Root directory [Default=.] |
| -b ADDRESS, --bind ADDRESS | Specify alternate bind address [Default=0.0.0.0] |
| -p PORT, --port PORT | Port to serve [Default=9090] |
| --password PASSWORD | Use a password to access the page. (No username) |
| --ssl | Enable transport encryption via SSL |
| --version | Show version |
| -h, --help | Show help |
## Examples
@ -48,6 +49,10 @@ Install using pip:
`updog -p 1234`
**Serve from 192.168.1.11 IP address and port 1234:**
`updog -b 192.168.1.11 -p 1234`
**Password protect the page:**
`updog --password examplePassword123!`

View File

@ -29,6 +29,8 @@ def parse_arguments():
parser.add_argument('-d', '--directory', metavar='DIRECTORY', type=read_write_directory, default=cwd,
help='Root directory\n'
'[Default=.]')
parser.add_argument('-b', '--bind', metavar='ADDRESS', type=str, default='0.0.0.0',
help='Specify alternate bind address [Default=0.0.0.0]')
parser.add_argument('-p', '--port', type=int, default=9090,
help='Port to serve [Default=9090]')
parser.add_argument('--password', type=str, default='', help='Use a password to access the page. (No username)')
@ -166,7 +168,7 @@ def main():
return True
# Inform user before server goes up
success('Serving {}...'.format(args.directory, args.port))
success('Serving {} from {}:{}...'.format(args.directory, args.bind, args.port))
def handler(signal, frame):
print()
@ -177,7 +179,7 @@ def main():
if args.ssl:
ssl_context = 'adhoc'
run_simple("0.0.0.0", int(args.port), app, ssl_context=ssl_context)
run_simple(args.bind, int(args.port), app, ssl_context=ssl_context)
if __name__ == '__main__':