diff options
author | Louis Vézina <[email protected]> | 2018-10-16 10:58:25 -0400 |
---|---|---|
committer | Louis Vézina <[email protected]> | 2018-10-16 10:58:25 -0400 |
commit | 67b722cce14eb30192135897c4e04f56f6a56327 (patch) | |
tree | 79c6bdb19b2575be9b401d1ac423fe6c7b8e6b1c | |
parent | 8a1dc9e275e3a8f09fb09fe0903c0eb5619c6e0c (diff) | |
download | bazarr-67b722cce14eb30192135897c4e04f56f6a56327.tar.gz bazarr-67b722cce14eb30192135897c4e04f56f6a56327.zip |
Continuing development
-rw-r--r-- | bazarr.py | 3 | ||||
-rw-r--r-- | bazarr/main.py | 8 | ||||
-rw-r--r-- | views/menu.tpl | 15 | ||||
-rw-r--r-- | views/system.tpl | 15 |
4 files changed, 33 insertions, 8 deletions
@@ -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}}';
}
});
}
|