From 56853d117d14df0a2636902e085a253394095486 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Thu, 10 Nov 2016 09:47:42 +0800 Subject: webui: bin/fg21sim-webui: implement argument "--no-browser" Now, by default, this executable will open the Web UI in a new browser tab, unless the "--no-browser" argument presents --- bin/fg21sim-webui | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/fg21sim-webui b/bin/fg21sim-webui index cff8ce0..9da61a3 100755 --- a/bin/fg21sim-webui +++ b/bin/fg21sim-webui @@ -19,6 +19,7 @@ import os import sys import logging import ipaddress +import webbrowser import tornado.ioloop from tornado.options import define, options, parse_command_line @@ -61,8 +62,13 @@ def main(): application = make_application(debug=options.debug) application.listen(options.port) - logger.info("Tornado started on: {protocol}://{host}:{port}".format( - protocol="http", host="localhost", port=options.port)) + url = "http://localhost:{port}".format(port=options.port) + logger.info("Tornado started") + logger.info("You can use the Web UI by accessing:\n\t{0}".format(url)) + if not options.no_browser: + # Open the Web UI in a new browser tab + webbrowser.open_new_tab(url) + logger.info("Hosts allowed to access the Web UI: {0}".format( options.hosts_allowed)) tornado.ioloop.IOLoop.current().start() -- cgit v1.2.2