Fix passing configuration via WSGI

Commit cb1072413961109d88ed1cc745437a0d1a143682 broke it since command
line is not processed in WSGI case.

Change-Id: Ice0105e24ab696aeafb3b30be55b3498e16efdc3
This commit is contained in:
Dmitry Tantsur 2021-09-23 16:58:59 +02:00
parent cb10724139
commit 569a02c1cc
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes configuring the emulator via environment parameters when ``main``
is not invoked (e.g. when using WSGI).

View File

@ -78,9 +78,10 @@ class Application(flask.Flask):
super().__init__(__name__)
# Turn off strict_slashes on all routes
self.url_map.strict_slashes = False
# This is needed for WSGI since it cannot process argv
self.configure(config_file=os.environ.get('SUSHY_EMULATOR_CONFIG'))
def configure(self, config_file=None, extra_config=None):
config_file = config_file or os.environ.get('SUSHY_EMULATOR_CONFIG')
if config_file:
self.config.from_pyfile(config_file)
if extra_config: