From cd04fb705f8273e33a8302490a00826b8479468f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 29 Dec 2012 12:11:49 +0100 Subject: [PATCH] New commandline options for debugging and specifying host/port of server to bind to, also added to readme. --- Cura/cura.py | 8 +++++++- Cura/webui/__init__.py | 5 +++-- README.md | 8 +++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cura/cura.py b/Cura/cura.py index 753f0f4..4160809 100644 --- a/Cura/cura.py +++ b/Cura/cura.py @@ -54,6 +54,12 @@ def main(): help="Slice the given files instead of opening them in Cura") parser.add_option("-w", "--web", action="store_true", dest="webui", help="Start the webui instead of the normal Cura UI") + parser.add_option("-d", "--debug", action="store_true", dest="debug", + help="Enable debug mode, currently only used by the webui") + parser.add_option("--web-host", action="store", type="string", default="0.0.0.0", dest="webHost", + help="Specify the host on which to bind the webui, defaults to 0.0.0.0 (all interfaces) if not set") + parser.add_option("--web-port", action="store", type="int", default=5000, dest="webPort", + help="Specify the port on which to bind the webui, defaults to 5000 if not set") (options, args) = parser.parse_args() if options.profile is not None: @@ -69,7 +75,7 @@ def main(): sliceRun.runSlice(args) elif options.webui: import Cura.webui as webapp - webapp.run() + webapp.run(host=options.webHost, port=options.webPort, debug=options.debug) else: #Place any unused arguments as last file, so Cura starts with opening those files. if len(args) > 0: diff --git a/Cura/webui/__init__.py b/Cura/webui/__init__.py index 54f6f1b..4e18197 100644 --- a/Cura/webui/__init__.py +++ b/Cura/webui/__init__.py @@ -236,5 +236,6 @@ def sizeof_fmt(num): def allowed_file(filename): return "." in filename and filename.rsplit(".", 1)[1] in ALLOWED_EXTENSIONS -def run(): - app.run(host="0.0.0.0", port=5000) +def run(host = "0.0.0.0", port = 5000, debug = False): + app.debug = debug + app.run(host=host, port=port, use_reloader=False) diff --git a/README.md b/README.md index 41ff889..827dc6d 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,8 @@ This fork of Cura includes a WebUI for remote printing via the browser. It depen its dependencies "werkzeug", "jinja2" and "itsdangerous", so you'll need those in order to run the WebUI. A simple `pip install -r requirements.txt` or `pip install flask` should take care of that. -Once installed, you can startup the WebUI instead of the regular Cura UI via the command-line option `--web` or `-w`. The -web interface will then be available on port 5000. If you want to change that (or the IP address the server binds to, -which currently is `0.0.0.0`), please take a look at the source code of `Cura/webui/__init__.py`. \ No newline at end of file +Once installed, you can startup the WebUI instead of the regular Cura UI via the command-line option `--web` or `-w`. By +default the web interface will bind to all interfaces on port 5000 (so pointing your browser to `http://127.0.0.1:5000` +will do the trick). If you want to change that, use the additional command line parameters `web-host` and `web-port`, +which accept the host ip to bind to and the numeric port number respectively. If for example you want to the server +to only listen on the local interface on port 8080, the command line would be `--web --web-host=127.0.0.1 --web-port=8080`. \ No newline at end of file