Skip to content

Commit

Permalink
Added IP and port options
Browse files Browse the repository at this point in the history
  • Loading branch information
Brikwerk committed Sep 16, 2020
1 parent 223ed1a commit 0bff151
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion nxbt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
parser.add_argument('-l', '--logfile', required=False, default=False, action='store_true',
help="""Enables logging to a file in the current working directory
instead of stderr.""")
parser.add_argument('-i', '--ip', required=False, default="0.0.0.0", type=str,
help="""Specifies the IP to run the webapp at. Defaults to 0.0.0.0""")
parser.add_argument('-p', '--port', required=False, default=8000, type=int,
help="""Specifies the port to run the webapp at. Defaults to 8000""")
args = parser.parse_args()


Expand Down Expand Up @@ -214,7 +218,7 @@ def main():

if args.command == 'webapp':
from .web import start_web_app
start_web_app()
start_web_app(ip=args.ip, port=args.port)
elif args.command == 'demo':
demo()
elif args.command == 'macro':
Expand Down
5 changes: 2 additions & 3 deletions nxbt/web/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import os
from threading import RLock
from time import perf_counter

from ..nxbt import Nxbt, PRO_CONTROLLER
from flask import Flask, render_template, request
Expand Down Expand Up @@ -103,8 +102,8 @@ def handle_macro(message):
nxbt.macro(index, macro)


def start_web_app():
eventlet.wsgi.server(eventlet.listen(('127.0.0.1', 8000)), app)
def start_web_app(ip='0.0.0.0', port=8000):
eventlet.wsgi.server(eventlet.listen((ip, port)), app)


if __name__ == "__main__":
Expand Down

0 comments on commit 0bff151

Please sign in to comment.