GitXplorerGitXplorer
m

flask-envconfig

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
9584333584beee81e15ff849c665893a2d4d6623

support Python 3

mmozillazg committed 9 years ago
Unverified
aab3c73267602635d5e7bb65f3bfb88b29a45879

Add license.

rromabysen committed 11 years ago
Unverified
1cf17e1ca78ae6202cac6e6e7867055d08b80611

Fix documentation error.

rromabysen committed 11 years ago
Unverified
8b590427fd9418a2c16a653c3a5efba649b0a25c

Added tag v0.2.0 for changeset c50aae0a6348

rromabysen committed 11 years ago
Unverified
b777efa130b1c2b43af48b557921298a5976175e

Update to use ast.literal_eval(), now supports more data types.

rromabysen committed 11 years ago
Unverified
39dc4ffe6c8fc55f9a8da2b2a7641b1670227fd5

Ignore .pyc files.

rromabysen committed 11 years ago

README

The README file for this repository.

About

Extension for configuring Flask from environment variables.

Requirements

  • Flask

Installation

::

pip install flask-envconfig

Usage

Simple usage:

::

from flask import Flask
from flask.ext.envconfig import EnvConfig

app = Flask(__name__)
env = EnvConfig(app)

Or, for the application factory pattern:

::

env = EnvConfig()
# At a later time
env.init_app(app)

Now set your configuration variables in your shell, .env file or whatever:

::

FLASK_DEBUG=True
FLASK_SECRET_KEY="Something_or_the_other"

By default only environments variables prefixed with FLASK_ are processed and added to app.config. The extension strips off the prefix so FLASK_DEBUG becomes app.config['DEBUG'] and so forth. The extension understands "True" to mean True, "False" to mean False and "None" to mean None. It also understands lists, tuples and dicts and numbers.

::

FLASK_TRUE=True
FLASK_FALSE=False
FLASK_NONE=None
FLASK_INTEGER=1
FLASK_FLOAT=1.1
FLASK_STRING="This is a string"
FLASK_LIST="['a', 'b', 'c']"
FLASK_TUPLE="('a', 'b', 'c')"
FLASK_DICT="{'a': 1, 'b': 6}"

The prefix can be changed if so desired:

::

EnvConfig(app, 'MYPREFIX_')

Or

::

env = EnvConfig()
env.init_app(app, 'MYPREFIX_')