Complete worked example
python
from flask import Flask
def create_app(label):
app = Flask(__name__)
app.config.update(TESTING=True, LABEL=label)
@app.get('/health')
def health():
return {'label': app.config['LABEL']}
return app
def inspect_apps(first, second):
left, right = create_app(first), create_app(second)
return [left.test_client().get('/health').json,
right.test_client().get('/health').json]- Reasoning
- The example defines a health route inside create_app, so its closure uses the particular app being constructed. Two test clients then request two independently configured applications.