2022-10-12 10:22:22 -04:00
|
|
|
import os
|
|
|
|
|
|
|
|
from spiffworkflow_backend import create_app
|
2023-05-26 20:01:08 -04:00
|
|
|
from spiffworkflow_backend.services.acceptance_test_fixtures import load_acceptance_test_fixtures
|
2022-10-12 10:22:22 -04:00
|
|
|
|
|
|
|
app = create_app()
|
2023-05-01 11:25:37 -04:00
|
|
|
|
2024-10-10 14:51:22 +00:00
|
|
|
num_proxies = 0
|
|
|
|
|
|
|
|
# this is the first configuration spiffworkflow-backend supported.
|
|
|
|
# you should use SPIFFWORKFLOW_BACKEND_PROXY_COUNT_FOR_PROXY_FIX instead, since it is more precise.
|
2023-05-01 11:25:37 -04:00
|
|
|
if app.config["SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX"]:
|
2024-10-10 14:51:22 +00:00
|
|
|
num_proxies = 1
|
|
|
|
|
|
|
|
if app.config["SPIFFWORKFLOW_BACKEND_PROXY_COUNT_FOR_PROXY_FIX"]:
|
|
|
|
num_proxies = int(app.config["SPIFFWORKFLOW_BACKEND_PROXY_COUNT_FOR_PROXY_FIX"])
|
|
|
|
|
|
|
|
if num_proxies > 0:
|
2023-05-01 21:38:47 +08:00
|
|
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
2023-05-01 11:25:37 -04:00
|
|
|
|
2024-10-10 14:51:22 +00:00
|
|
|
# https://flask.palletsprojects.com/en/2.2.x/deploying/proxy_fix/
|
|
|
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=num_proxies, x_proto=num_proxies, x_host=num_proxies, x_prefix=num_proxies)
|
2022-10-12 10:22:22 -04:00
|
|
|
|
|
|
|
# this is in here because when we put it in the create_app function,
|
|
|
|
# it also loaded when we were running migrations, which resulted in a chicken/egg thing.
|
|
|
|
if os.environ.get("SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA") == "true":
|
|
|
|
with app.app_context():
|
2022-10-12 15:28:52 -04:00
|
|
|
load_acceptance_test_fixtures()
|