aboutsummaryrefslogtreecommitdiffstats
path: root/bin/fg21sim-webui
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-11-10 09:47:42 +0800
committerAaron LI <aaronly.me@outlook.com>2016-11-10 09:47:42 +0800
commit56853d117d14df0a2636902e085a253394095486 (patch)
tree09dc66904bfb1e46d62058098a289db64912f402 /bin/fg21sim-webui
parentc0fff3ca807ec4f3714701f3258cf31f21a905d9 (diff)
downloadfg21sim-56853d117d14df0a2636902e085a253394095486.tar.bz2
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
Diffstat (limited to 'bin/fg21sim-webui')
-rwxr-xr-xbin/fg21sim-webui10
1 files 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()