Helper utility to manage Flask app configuration. FlaskConfig checks that the required config variables are present, and loads them into the app config. It will also check for optional configs, but will not return an error if they are not present.
pip install flask-confighelper
The flask-confighelper
package will read the ENVIRONMENT
key currently set, and will use the value of that key to identify which *Config
object to load
from flask import Flask
from flask_config import FlaskConfigHelper
app = Flask(__name__)
FlaskConfigHelper(app, config_module='config')
print app.config['DATABASE_URI']
class Config(object):
PORT = 'required'
OPTIONAL = 'optional'
class ProductionConfig(Config):
DATABASE_URI = 'required'
TOKEN = 'required'
OPTIONAL = 'optional'
class DevelopmentConfig(Config):
DATABASE_URI = 'required'
DEBUG = 'optional'
OPTIONAL = 'optional'
class TestingConfig(Config):
TESTING = 'required'