Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bind argument #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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