Configuration

Drakken’s default configuration dictionary is in drakken.config. You can override or extend the configuration by importing settings in a JSON or YAML file.

Create a myapp.json file containing the following:

{
 "APP_NAME": "My test app",
}

Add the following to app.py:

import drakken.config as config

config_file_path = os.getenv('MY_CONFIG_PATH')
config.load(config_file_path)
name = config.get('APP_NAME')

In your shell:

> export MY_CONFIG_PATH='/path/to/myapp.json'
> python app.py

Name

Usage

APP_NAME

Application name used in logging.

DATABASE_URL

Database connection string.

DEBUG

Boolean: set to True to display server error traceback during unit tests. Default: False.

STATIC_DIR

Static file path. Default: ‘/static’.

STATIC_PATHS

List of static file paths outside STATIC_DIR. Default: [].

TEMPLATE_DIR

Template file path. Default: “templates”.

TRAILING_SLASH_REDIRECT

Redirect visitors who forget a trailing slash or add one by accident. Default: False.

Session Handling

MIN_PASSWORD_LENGTH

Minimum number of password characters. Default: 8.

MAX_PASSWORD_LENGTH

Maximum number of password characters. Keep it small to prevent password DOS attacks. Default: 64.

SALT_BYTES

Password salt string length in bytes. Default: 24.

SESSION_COOKIE_AGE

Session cookie age in seconds. Set to 0 to close the session when the browser closes. Default: 86400 (1 day).

SESSION_COOKIE_SECURE

Boolean: if True, session ID cookie is sent only if SSL is detected. Default: False.

SESSION_TOKEN_BYTES

Session token length in bytes. Default: 24.

USERNAME

Boolean: if True, log in with user name. If False, log in with email address. Default: False.