Add argparse to assign different host and port via command line
This commit is contained in:
parent
44f1bcac33
commit
4a9a16e792
11
app.py
11
app.py
|
@ -10,7 +10,16 @@ from bottle import (
|
||||||
|
|
||||||
import thesethreewords as these
|
import thesethreewords as these
|
||||||
import sys
|
import sys
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
|
parser = ArgumentParser(
|
||||||
|
prog='these-3-words-api',
|
||||||
|
description='Hosts an API for these-3-words API',
|
||||||
|
epilog='Defaults to: 0.0.0.0:8080')
|
||||||
|
parser.add_argument('--host', default='0.0.0.0',
|
||||||
|
help='Host to bind to (default: 0.0.0.0)')
|
||||||
|
parser.add_argument('--port', type=int, default=8080, help='Port to bind to (default: 8080)')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
example_locs = [("sydney", (-33.867480754852295, 151.20700120925903)),
|
example_locs = [("sydney", (-33.867480754852295, 151.20700120925903)),
|
||||||
("battery", (40.70329427719116, -74.0170168876648)),
|
("battery", (40.70329427719116, -74.0170168876648)),
|
||||||
|
@ -90,6 +99,6 @@ def hashToLatLng(threewords):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run(host='0.0.0.0', port=8080)
|
run(host=args.host, port=args.port)
|
||||||
|
|
||||||
app = bottle.default_app()
|
app = bottle.default_app()
|
||||||
|
|
Loading…
Reference in New Issue