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. If it’s not an absolute path, it’s treated as a path relative to the app module. Default: ‘static’. |
TEMPLATE_DIR |
Template file path. |
TRAILING_SLASH_REDIRECT |
Redirect visitors who forget a trailing slash or add one by accident. Default: False. |
CSRF_TOKEN_BYTES |
Cross-Site Request Forgery token length in bytes. |
MIN_PASSWORD_LENGTH |
Minimum number of password characters. |
MAX_PASSWORD_LENGTH |
Maximum number of password characters. Keep it small to prevent password DOS attacks. |
SALT_BYTES |
Password salt string length in bytes. |
SESSION_COOKIE_AGE |
Session cookie age in seconds. Set to 0 to close the session when the browser closes. |
SESSION_COOKIE_SECURE |
Boolean: if True, session ID cookie is sent only if SSL is detected. |
SESSION_TOKEN_BYTES |
Session token length in bytes. |
USERNAME |
Boolean: if True, log in with user name. If False, log in with email address. |
ADMINS |
List of administrator email addresses to receive server mail. |
DEFAULT_FROM_EMAIL |
Email From address the server uses. |
EMAIL_HOST |
Email host name. Default: ‘localhost’. |
EMAIL_HOST_PASSWORD |
Email server password. |
EMAIL_HOST_USER |
Email server user name, for logging into an external mail provider. |
EMAIL_PORT |
Email port. |
EMAIL_REQUIRE_SSL |
Boolean: if True, email server requires SSL. Default: False |
ADMIN_MAIL_LIMIT |
Integer: maximum amount of admin email sent. |
ADMIN_MAIL_UNIT |
SECOND, MINUTE, HOUR, or DAY. |