[Script] Respect root if running devel server
This commit is contained in:
parent
2d6b86e2eb
commit
40651c3279
|
@ -4,6 +4,26 @@ import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
from werkzeug.middleware.dispatcher import DispatcherMiddleware
|
||||||
|
|
||||||
|
from flaschengeist.config import config
|
||||||
|
|
||||||
|
|
||||||
|
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()]
|
||||||
|
|
||||||
|
|
||||||
class InterfaceGenerator:
|
class InterfaceGenerator:
|
||||||
|
@ -100,15 +120,11 @@ def run(arguments):
|
||||||
|
|
||||||
app = create_app()
|
app = create_app()
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
|
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix=config["FLASCHENGEIST"].get("root", ""))
|
||||||
if arguments.debug:
|
if arguments.debug:
|
||||||
app.run(arguments.host, arguments.port, debug=True)
|
app.run(arguments.host, arguments.port, debug=True)
|
||||||
else:
|
else:
|
||||||
try:
|
app.run(arguments.host, arguments.port, debug=False)
|
||||||
import bjoern
|
|
||||||
|
|
||||||
bjoern.run(app, arguments.host, arguments.port, reuse_port=True)
|
|
||||||
except ImportError:
|
|
||||||
app.run(arguments.host, arguments.port, debug=False)
|
|
||||||
|
|
||||||
|
|
||||||
def export(arguments):
|
def export(arguments):
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -21,7 +21,7 @@ setup(
|
||||||
# Needed for python < 3.7
|
# Needed for python < 3.7
|
||||||
"backports-datetime-fromisoformat",
|
"backports-datetime-fromisoformat",
|
||||||
],
|
],
|
||||||
extras_require={"ldap": ["flask_ldapconn", "ldap3"], "bjoern": ["bjoern"]},
|
extras_require={"ldap": ["flask_ldapconn", "ldap3"]},
|
||||||
entry_points={
|
entry_points={
|
||||||
"flaschengeist.plugin": [
|
"flaschengeist.plugin": [
|
||||||
# Authentication providers
|
# Authentication providers
|
||||||
|
|
Loading…
Reference in New Issue