Merge pull request #2 from mbeigel/choose-port
Add option to choose port from command line
This commit is contained in:
commit
05df765a64
|
@ -6,7 +6,10 @@ This is the source code for my post on [Building a Blockchain](https://medium.co
|
|||
|
||||
1. Make sure [Python 3.6+](https://www.python.org/downloads/) is installed
|
||||
1. Install requirements: `$ pip install -r requirements.txt`
|
||||
1. Run the server: `$ python blockchain.py`
|
||||
1. Run the server:
|
||||
* `$ python blockchain.py`
|
||||
* `$ python blockchain.py -p 5001`
|
||||
* `$ python blockchain.py --port 5002`
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
@ -279,4 +279,11 @@ def consensus():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5000)
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('-p', '--port', default=5000, type=int, help='port to listen on')
|
||||
args = parser.parse_args()
|
||||
port = args.port
|
||||
|
||||
app.run(host='0.0.0.0', port=port)
|
||||
|
|
Loading…
Reference in New Issue