settei.presets.flask — Preset for Flask apps

New in version 0.2.0.

class settei.presets.flask.WebConfiguration(config: Mapping[str, object] = {}, **kwargs)

Settei configuration for the Flask. For more information, See the example below:

config = WebConfiguration.from_path('config.toml')
app = Flask(__name__)

def before_first_request():

Trigger the web.on_loaded hooks. You should invoke this function when the WSGI app is ready with the WSGI app as argument. You may want to use flask.Flask.before_first_request.

web.on_loaded hook can be a Python code or list of module path.

When web.on_loaded is a single string, it will be interpreted as Python code. The configuration and the WSGI app is injected as self and app each:

on_loaded = """
print('Hello, world!')
print('self is configuration!: {}'.format(self))
print('app is flask app!: {}'.format(app))

When web.on_loaded is a list of string, it will be interpreted as module paths:

on_loaded = [

The hooks must receive two arguments, Configuration and flask.Flask:

def sample_hook(conf: Configuration, app: Flask):
    print('Hello, world!')
    print('conf is configuration!: {}'.format(conf))
    print('app is flask app!: {}'.format(app))
Parameters:app (flask.Flask) – a ready wsgi/flask app

Changed in version 0.5.2: Hooks list added


(typing.Mapping) The configuration maping for web that will go to flask.Flask.config.


Whether to enable debug mode. On debug mode the server will reload itself on code changes, and provide a helpful debugger when things go wrong.