From 67b722cce14eb30192135897c4e04f56f6a56327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 16 Oct 2018 10:58:25 -0400 Subject: [PATCH] Continuing development --- bazarr.py | 3 +-- bazarr/main.py | 8 ++++++-- views/menu.tpl | 15 +++++++++++++-- views/system.tpl | 15 +++++++++++++-- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/bazarr.py b/bazarr.py index adc39d7bc..06c39ead2 100644 --- a/bazarr.py +++ b/bazarr.py @@ -20,14 +20,13 @@ for opt, arg in opts: dir_name = os.path.dirname(__file__) def start_bazarr(): - script = [sys.executable, os.path.normcase(os.path.join(globals()['dir_name'], 'bazarr/main.py'))] + globals()['arguments'] + script = [sys.executable, "-u", os.path.normcase(os.path.join(globals()['dir_name'], 'bazarr/main.py'))] + globals()['arguments'] ep = sp.Popen(script, stdout=sp.PIPE, stderr=sp.STDOUT, stdin=sp.PIPE) print "Bazarr starting..." try: for line in iter(ep.stdout.readline, ''): sys.stdout.write(line) - sys.stdout.flush() except KeyboardInterrupt: pass diff --git a/bazarr/main.py b/bazarr/main.py index cbb8c87a1..1beb39963 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -67,7 +67,7 @@ if get_proxy_settings()[0] != 'None': os.environ['HTTPS_PROXY'] = str(proxy) os.environ['NO_PROXY'] = str(get_proxy_settings()[5]) -from bottle import route, run, template, static_file, request, redirect, response, HTTPError, app +from bottle import route, run, template, static_file, request, redirect, response, HTTPError, app, hook import bottle bottle.TEMPLATE_PATH.insert(0, os.path.join(os.path.dirname(__file__), '../views/')) bottle.debug(True) @@ -166,6 +166,11 @@ def post_get(name, default=''): return request.POST.get(name, default).strip() +@hook('before_request') +def enable_cors(): + response.headers['Access-Control-Allow-Origin'] = '*' + + @route(base_url + 'login') def login_form(): msg = bottle.request.query.get('msg', '') @@ -1695,7 +1700,6 @@ server = CherryPyWSGIServer((str(ip), int(port)), app) try: logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url)) print 'Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url) - sys.stdout.flush() server.start() except KeyboardInterrupt: shutdown() diff --git a/views/menu.tpl b/views/menu.tpl index af62aa4a1..5304e93fb 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -179,11 +179,22 @@ }); }) + % from get_settings import get_general_settings + % ip = get_general_settings()[0] + % port = get_general_settings()[1] + % base_url = get_general_settings()[2] + "/" + + if ("{{ip}}" == "0.0.0.0") { + public_ip = window.location.hostname; + } else { + public_ip = "{{ip}}"; + } + function ping() { $.ajax({ - url: '{{base_url}}', + url: 'http://' + public_ip + ':{{port}}{{base_url}}', success: function(result) { - window.location.reload(); + window.location.href= 'http://' + public_ip + ':{{port}}{{base_url}}'; } }); } diff --git a/views/system.tpl b/views/system.tpl index 28386862c..77c9349b2 100644 --- a/views/system.tpl +++ b/views/system.tpl @@ -235,11 +235,22 @@ }); }) + % from get_settings import get_general_settings + % ip = get_general_settings()[0] + % port = get_general_settings()[1] + % base_url = get_general_settings()[2] + "/" + + if ("{{ip}}" == "0.0.0.0") { + public_ip = window.location.hostname; + } else { + public_ip = "{{ip}}"; + } + function ping() { $.ajax({ - url: '{{base_url}}', + url: 'http://' + public_ip + ':{{port}}{{base_url}}', success: function(result) { - window.location.reload(); + window.location.href= 'http://' + public_ip + ':{{port}}{{base_url}}'; } }); }