Skip to content

Commit

Permalink
Add bind argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Milos Buncic committed May 20, 2022
1 parent 28a1ac1 commit 1df84b2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ Install using pip:

## Usage

`updog [-d DIRECTORY] [-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 |
`updog [-d DIRECTORY] [-b ADDRESS] [-p PORT] [--password PASSWORD] [--ssl]`

| 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

Expand All @@ -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!`
Expand Down
6 changes: 4 additions & 2 deletions updog/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)')
Expand Down Expand Up @@ -166,7 +168,7 @@ def verify_password(username, password):
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()
Expand All @@ -177,7 +179,7 @@ def handler(signal, frame):
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__':
Expand Down

0 comments on commit 1df84b2

Please sign in to comment.