Fix premature loading of static folder path

This commit is contained in:
PV Tejas 2023-07-16 16:44:14 +00:00
parent 83582435e9
commit 0b2f0378c1

View file

@ -12,9 +12,6 @@ def create_app(test_config=None):
NAME='Flaskr' NAME='Flaskr'
) )
if app.config.get('STATIC_FOLDER') is not None:
app.static_folder = app.config.get('STATIC_FOLDER')
app.wsgi_app = ProxyFix( app.wsgi_app = ProxyFix(
app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1 app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1
) )
@ -26,6 +23,9 @@ def create_app(test_config=None):
# load the test config if passed in # load the test config if passed in
app.config.from_mapping(test_config) app.config.from_mapping(test_config)
if app.config.get('STATIC_FOLDER') is not None:
app.static_folder = app.config.get('STATIC_FOLDER')
# ensure the instance folder exists # ensure the instance folder exists
try: try:
os.makedirs(app.instance_path) os.makedirs(app.instance_path)