From 0bff151596c0c8a8b8bb3f8abd9bddb62d029f50 Mon Sep 17 00:00:00 2001 From: Brikwerk Date: Wed, 16 Sep 2020 16:16:04 -0700 Subject: [PATCH] Added IP and port options --- nxbt/cli.py | 6 +++++- nxbt/web/app.py | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nxbt/cli.py b/nxbt/cli.py index 4d36141..a142a58 100644 --- a/nxbt/cli.py +++ b/nxbt/cli.py @@ -38,6 +38,10 @@ parser.add_argument('-d', '--debug', required=False, default=False, action='stor 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() @@ -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': diff --git a/nxbt/web/app.py b/nxbt/web/app.py index 0712eaf..3cb5625 100644 --- a/nxbt/web/app.py +++ b/nxbt/web/app.py @@ -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 @@ -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__":