From 4b0f1316fcdd74580d7fcd6893c6657f4c5dd1a2 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Thu, 31 Aug 2023 08:32:18 -0400 Subject: try DispatcherMiddleware --- newspipe/bootstrap.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/newspipe/bootstrap.py b/newspipe/bootstrap.py index 9160c857..a5ebc862 100644 --- a/newspipe/bootstrap.py +++ b/newspipe/bootstrap.py @@ -3,6 +3,7 @@ import calendar import logging import os +from werkzeug.middleware.dispatcher import DispatcherMiddleware from flask import Flask from flask import request from flask_babel import Babel @@ -44,14 +45,14 @@ def set_logging( handler.setLevel(log_level) logger.setLevel(log_level) -class ReverseProxied(object): - def __init__(self, app, script_name): - self.app = app - self.script_name = script_name - - def __call__(self, environ, start_response): - environ['SCRIPT_NAME'] = self.script_name - return self.app(environ, start_response) +#class ReverseProxied(object): +# def __init__(self, app, script_name): +# self.app = app +# self.script_name = script_name +# +# def __call__(self, environ, start_response): +# environ['SCRIPT_NAME'] = self.script_name +# return self.app(environ, start_response) # Create Flask application application = Flask(__name__, instance_relative_config=True) @@ -72,7 +73,9 @@ else: set_logging(application.config["LOG_PATH"]) if "PREFIX" in application.config: - application.wsgi_app = ReverseProxied(application.wsgi_app, script_name=application.config["PREFIX"]) + #application.wsgi_app = ReverseProxied(application.wsgi_app, script_name=application.config["PREFIX"]) + _app = application + application = DispatcherMiddleware(None,str({application.config["PREFIX"]}):_app}) db = SQLAlchemy(application) -- cgit