Python flask.Config() Examples
The following are 7
code examples of flask.Config().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
flask
, or try the search function
.
Example #1
Source File: flask.py From keycloak-client with GNU General Public License v3.0 | 6 votes |
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)
Example #2
Source File: configure_app_hook.py From flask-unchained with MIT License | 6 votes |
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)
Example #3
Source File: configure_app_hook.py From flask-unchained with MIT License | 6 votes |
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
Example #4
Source File: flask.py From keycloak-client with GNU General Public License v3.0 | 5 votes |
def __init__(self, config: Config): self.config = config
Example #5
Source File: configure_app_hook.py From flask-unchained with MIT License | 5 votes |
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
Example #6
Source File: updateGraph.py From fc00.org with GNU General Public License v3.0 | 5 votes |
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)
Example #7
Source File: __init__.py From fence with Apache License 2.0 | 4 votes |
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)