本文整理汇总了Python中flask.Config方法的典型用法代码示例。如果您正苦于以下问题:Python flask.Config方法的具体用法?Python flask.Config怎么用?Python flask.Config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask
的用法示例。
在下文中一共展示了flask.Config方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import flask [as 别名]
# 或者: from flask import Config [as 别名]
def __init__(
self,
app: Flask,
config: Config,
session_interface: SessionInterface,
callback_url: str = "http://localhost:5000/kc/callback",
redirect_uri: str = "/",
logout_uri: str = "/kc/logout",
) -> None:
self.app = app
self.config = config
self.session_interface = session_interface
self.callback_url = callback_url
self.redirect_uri = redirect_uri
self.logout_uri = logout_uri
self.kc = Client(callback_url)
self.proxy_app = ProxyApp(config)
示例2: run_hook
# 需要导入模块: import flask [as 别名]
# 或者: from flask import Config [as 别名]
def run_hook(self,
app: FlaskUnchained,
bundles: List[Bundle],
unchained_config: Optional[Dict[str, Any]] = None,
) -> None:
"""
For each bundle in ``unchained_config.BUNDLES``, iterate through that
bundle's class hierarchy, starting from the base-most bundle. For each
bundle in that order, look for a ``config`` module, and if it exists,
update ``app.config`` with the options first from a base ``Config`` class,
if it exists, and then also if it exists, from an env-specific config class:
one of ``DevConfig``, ``ProdConfig``, ``StagingConfig``, or ``TestConfig``.
"""
BundleConfig._set_current_app(app)
self.apply_default_config(app, bundles and bundles[-1] or None)
for bundle in bundles:
app.config.from_mapping(self.get_bundle_config(bundle, app.env))
_config_overrides = (unchained_config.get('_CONFIG_OVERRIDES')
if unchained_config else None)
if _config_overrides and isinstance(_config_overrides, dict):
app.config.from_mapping(_config_overrides)
示例3: _get_bundle_config
# 需要导入模块: import flask [as 别名]
# 或者: from flask import Config [as 别名]
def _get_bundle_config(self,
bundle: Union[AppBundle, Bundle],
env: Union[DEV, PROD, STAGING, TEST],
) -> flask.Config:
bundle_config_modules = self.import_bundle_modules(bundle)
if not bundle_config_modules:
return flask.Config('.')
bundle_config_module = bundle_config_modules[0]
base_config = getattr(bundle_config_module, BASE_CONFIG_CLASS, None)
env_config = getattr(bundle_config_module, ENV_CONFIG_CLASSES[env], None)
merged = flask.Config('.')
for config in [base_config, env_config]:
if config:
merged.from_object(config)
return merged
示例4: get_bundle_config
# 需要导入模块: import flask [as 别名]
# 或者: from flask import Config [as 别名]
def get_bundle_config(self,
bundle: Bundle,
env: Union[DEV, PROD, STAGING, TEST],
) -> flask.Config:
if isinstance(bundle, AppBundle):
return self._get_bundle_config(bundle, env)
config = flask.Config('.')
for bundle_ in bundle._iter_class_hierarchy():
config.update(self._get_bundle_config(bundle_, env))
return config
示例5: load_graph_from_db
# 需要导入模块: import flask [as 别名]
# 或者: from flask import Config [as 别名]
def load_graph_from_db(time_limit):
config = Config('./')
config.from_pyfile('web_config.cfg')
with NodeDB(config) as db:
nodes = db.get_nodes(time_limit)
edges = db.get_edges(nodes, 60*60*24*7)
return (nodes, edges)
示例6: app_config
# 需要导入模块: import flask [as 别名]
# 或者: from flask import Config [as 别名]
def app_config(
app, settings="fence.settings", root_dir=None, config_path=None, file_name=None
):
"""
Set up the config for the Flask app.
"""
if root_dir is None:
root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
logger.info("Loading settings...")
# not using app.config.from_object because we don't want all the extra flask cfg
# vars inside our singleton when we pass these through in the next step
settings_cfg = flask.Config(app.config.root_path)
settings_cfg.from_object(settings)
# dump the settings into the config singleton before loading a configuration file
config.update(dict(settings_cfg))
# load the configuration file, this overwrites anything from settings/local_settings
config.load(
config_path=config_path,
search_folders=CONFIG_SEARCH_FOLDERS,
file_name=file_name,
)
# load all config back into flask app config for now, we should PREFER getting config
# directly from the fence config singleton in the code though.
app.config.update(**config._configs)
_setup_arborist_client(app)
_setup_data_endpoint_and_boto(app)
_load_keys(app, root_dir)
_set_authlib_cfgs(app)
app.storage_manager = StorageManager(config["STORAGE_CREDENTIALS"], logger=logger)
app.debug = config["DEBUG"]
# Following will update logger level, propagate, and handlers
get_logger(__name__, log_level="debug" if config["DEBUG"] == True else "info")
_setup_oidc_clients(app)
_check_s3_buckets(app)