def make_flask_app(config, username, password, url_prefix):
"""Return Flask app with default configuration and registered blueprint."""
app = Flask(__name__)
# Start configuration with our built in defaults.
app.config.from_object(default_settings)
# Override with any settings in config file, if given.
if config:
app.config.from_object(importlib.import_module(config))
# Override from a configuration file in the env variable, if present.
if 'RQ_SCHEDULER_DASHBOARD_SETTINGS' in os.environ:
app.config.from_envvar('RQ_SCHEDULER_DASHBOARD_SETTINGS')
# Optionally add basic auth to blueprint and register with app.
if username:
add_basic_auth(blueprint, username, password)
app.register_blueprint(blueprint, url_prefix=url_prefix)
return app
评论列表
文章目录