mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-10 16:57:45 +08:00
Fix for base_url
This commit is contained in:
parent
df24964175
commit
b71e69a857
29 changed files with 22 additions and 7 deletions
|
@ -11,7 +11,7 @@ defaults = {
|
|||
'general': {
|
||||
'ip': '0.0.0.0',
|
||||
'port': '6767',
|
||||
'base_url': '/',
|
||||
'base_url': '',
|
||||
'path_mappings': '[]',
|
||||
'debug': 'False',
|
||||
'branch': 'master',
|
||||
|
|
|
@ -45,7 +45,6 @@ from six import text_type, PY2
|
|||
from datetime import timedelta
|
||||
from get_languages import load_language_in_db, language_from_alpha3, language_from_alpha2, alpha2_from_alpha3
|
||||
from flask import Flask, make_response, request, redirect, abort, render_template, Response, session, flash, url_for, send_file
|
||||
from flask_cors import CORS
|
||||
|
||||
from get_providers import get_providers, get_providers_auth, list_throttled_providers
|
||||
from get_series import *
|
||||
|
@ -65,13 +64,31 @@ from subliminal_patch.core import SUBTITLE_EXTENSIONS
|
|||
from flask_debugtoolbar import DebugToolbarExtension
|
||||
from functools import wraps
|
||||
|
||||
|
||||
class PrefixMiddleware(object):
|
||||
|
||||
def __init__(self, app, prefix=''):
|
||||
self.app = app
|
||||
self.prefix = prefix
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
|
||||
if environ['PATH_INFO'].startswith(self.prefix):
|
||||
environ['PATH_INFO'] = environ['PATH_INFO'][len(self.prefix):]
|
||||
environ['SCRIPT_NAME'] = self.prefix
|
||||
return self.app(environ, start_response)
|
||||
else:
|
||||
start_response('404', [('Content-Type', 'text/plain')])
|
||||
return ["This url does not belong to the app.".encode()]
|
||||
|
||||
# Flask Setup
|
||||
app = Flask(__name__,
|
||||
template_folder=os.path.join(os.path.dirname(__file__), '..', 'views'),
|
||||
static_folder=os.path.join(os.path.dirname(__file__), '..', 'static'))
|
||||
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix=base_url)
|
||||
|
||||
app.config["APPLICATION_ROOT"] = base_url
|
||||
app.config["SECRET_KEY"] = 'test'
|
||||
|
||||
if args.dev:
|
||||
app.config["DEBUG"] = True
|
||||
# Flask-Debuger
|
||||
|
@ -91,8 +108,6 @@ app.register_blueprint(api_bp)
|
|||
|
||||
from SSE import event_stream
|
||||
|
||||
# Add Cors
|
||||
CORS(app)
|
||||
|
||||
# Check and install update on startup when running on Windows from installer
|
||||
if args.release_update:
|
||||
|
@ -532,9 +547,9 @@ def image_proxy_movies(url):
|
|||
@login_required
|
||||
def redirect_root():
|
||||
if settings.general.getboolean('use_sonarr'):
|
||||
return redirect('/series')
|
||||
return redirect(url_for('series'))
|
||||
elif settings.general.getboolean('use_radarr'):
|
||||
return redirect('/movies')
|
||||
return redirect(url_for('movies'))
|
||||
elif not settings.general.enabled_providers:
|
||||
return redirect('/wizard')
|
||||
else:
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue