diff --git a/onionr/onionrcommands/openwebinterface.py b/onionr/onionrcommands/openwebinterface.py index 24689ce0..20bf2356 100755 --- a/onionr/onionrcommands/openwebinterface.py +++ b/onionr/onionrcommands/openwebinterface.py @@ -21,6 +21,20 @@ import webbrowser import logger from onionrutils import getclientapiserver import config + +def get_url(): + try: + url = getclientapiserver.get_client_API_server() + except FileNotFoundError: + url = "" + logger.error('Onionr seems to not be running (could not get api host)', terminal=True) + else: + url = 'http://%s/#%s' % (url, config.get('client.webpassword')) + logger.info('Onionr web interface URL: ' + url, terminal=True) + return url + +get_url.onionr_help = "Shows the Onionr web interface URL with API key" + def open_home(): try: url = getclientapiserver.get_client_API_server() diff --git a/onionr/onionrcommands/parser/arguments.py b/onionr/onionrcommands/parser/arguments.py index 341ea058..3cd110e8 100644 --- a/onionr/onionrcommands/parser/arguments.py +++ b/onionr/onionrcommands/parser/arguments.py @@ -44,6 +44,7 @@ def get_arguments()->dict: ('restart',): restartonionr.restart, ('add-address', 'addaddress', 'addadder'): keyadders.add_address, ('openhome', 'gui', 'openweb', 'open-home', 'open-web'): openwebinterface.open_home, + ('get-url', 'url', 'get-web'): openwebinterface.get_url, ('add-site', 'addsite', 'addhtml', 'add-html'): filecommands.add_html, ('addfile', 'add-file'): filecommands.add_file, ('get-file', 'getfile'): filecommands.get_file,