From 815f03145c8b8d1ab6dfeb04aceb13587b979cac Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Sun, 20 Mar 2016 22:33:03 +0100 Subject: [PATCH] Use specific host and port for 'openslides start'. (Fixes #1987) --- openslides/__main__.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/openslides/__main__.py b/openslides/__main__.py index 3bed8dc74..6ba08126d 100644 --- a/openslides/__main__.py +++ b/openslides/__main__.py @@ -97,6 +97,16 @@ def get_parser(): '--no-browser', action='store_true', help='Do not launch the default web browser.') + subcommand_start.add_argument( + '--host', + action='store', + default='0.0.0.0', + help='IP address to listen on. Default is 0.0.0.0.') + subcommand_start.add_argument( + '--port', + action='store', + default='8000', + help='Port to listen on. Default is 8000.') subcommand_start.add_argument( '--settings_path', action='store', @@ -165,12 +175,17 @@ def start(args): execute_from_command_line(['manage.py', 'migrate']) + # Open the browser if not args.no_browser: - start_browser('http://localhost:8000') + if args.host == '0.0.0.0': + # Windows does not support 0.0.0.0, so use 'localhost' instead + start_browser('http://localhost:%s' % args.port) + else: + start_browser('http://%s:%s' % (args.host, args.port)) # Start the webserver # Tell django not to reload. OpenSlides uses the reload method from tornado - execute_from_command_line(['manage.py', 'runserver', '0.0.0.0:8000', '--noreload']) + execute_from_command_line(['manage.py', 'runserver', '%s:%s' % (args.host, args.port), '--noreload']) def createsettings(args):