app.config 正しくは、flask.config.Configについてメモ。
こいつは、Flaskが呼ばれた時に使う変数 variable 群と、ちょっぴりユーティリティーらしい。

In [23]: import flask

In [26]: app = flask.Flask(__name__)

In [27]: type(app.config)
Out[27]: flask.config.Config

In [28]: app.config
Out[28]: <Config {DEBUG: False, PREFERRED_URL_SCHEME: http, TRAP_HTTP_EXCEPTIONS: False, SERVER_NAME: None, APPLICATION_ROOT: None, JSON_SORT_KEYS: True, USE_X_SENDFILE: False, PRESERVE_CONTEXT_ON_EXCEPTION: None, PERMANENT_SESSION_LIFETIME: datetime.timedelta(31), SESSION_COOKIE_DOMAIN: None, TRAP_BAD_REQUEST_ERRORS: False, PROPAGATE_EXCEPTIONS: None, SEND_FILE_MAX_AGE_DEFAULT: 43200, JSON_AS_ASCII: True, SECRET_KEY: None, SESSION_COOKIE_SECURE: False, MAX_CONTENT_LENGTH: None, LOGGER_NAME: __main__, SESSION_COOKIE_PATH: None, SESSION_COOKIE_HTTPONLY: True, TESTING: False, SESSION_COOKIE_NAME: session, JSONIFY_PRETTYPRINT_REGULAR: True}>

ふーん、、、
で、変数群は、dictと同じ要領で呼び出せる。

In [30]: app.config.items
Out[30]: <function Config.items>

In [31]: app.config.items()
Out[31]: dict_items([(DEBUG, False), (PREFERRED_URL_SCHEME, http), (TRAP_HTTP_EXCEPTIONS, False), (SERVER_NAME, None), (APPLICATION_ROOT, None), (JSON_SORT_KEYS, True), (USE_X_SENDFILE, False), (PRESERVE_CONTEXT_ON_EXCEPTION, None), (PERMANENT_SESSION_LIFETIME, datetime.timedelta(31)), (SESSION_COOKIE_DOMAIN, None), (TRAP_BAD_REQUEST_ERRORS, False), (PROPAGATE_EXCEPTIONS, None), (SEND_FILE_MAX_AGE_DEFAULT, 43200), (JSON_AS_ASCII, True), (SECRET_KEY, None), (SESSION_COOKIE_SECURE, False), (MAX_CONTENT_LENGTH, None), (LOGGER_NAME, __main__), (SESSION_COOKIE_PATH, None), (SESSION_COOKIE_HTTPONLY, True), (TESTING, False), (SESSION_COOKIE_NAME, session), (JSONIFY_PRETTYPRINT_REGULAR, True)])

In [32]: app.config.keys()
Out[32]: dict_keys([DEBUG, PREFERRED_URL_SCHEME, TRAP_HTTP_EXCEPTIONS, SERVER_NAME, APPLICATION_ROOT, JSON_SORT_KEYS, USE_X_SENDFILE, PRESERVE_CONTEXT_ON_EXCEPTION, PERMANENT_SESSION_LIFETIME, SESSION_COOKIE_DOMAIN, TRAP_BAD_REQUEST_ERRORS, PROPAGATE_EXCEPTIONS, SEND_FILE_MAX_AGE_DEFAULT, JSON_AS_ASCII, SECRET_KEY, SESSION_COOKIE_SECURE, MAX_CONTENT_LENGTH, LOGGER_NAME, SESSION_COOKIE_PATH, SESSION_COOKIE_HTTPONLY, TESTING, SESSION_COOKIE_NAME, JSONIFY_PRETTYPRINT_REGULAR])

dirしてみる。

In [33]: dir(app.config)
Out[33]: 
[__class__,
 __contains__,
 __delattr__,
 __delitem__,
 __dict__,
 __dir__,
 __doc__,
 __eq__,
 __format__,
 __ge__,
 __getattribute__,
 __getitem__,
 __gt__,
 __hash__,
 __init__,
 __iter__,
 __le__,
 __len__,
 __lt__,
 __module__,
 __ne__,
 __new__,
 __reduce__,
 __reduce_ex__,
 __repr__,
 __setattr__,
 __setitem__,
 __sizeof__,
 __str__,
 __subclasshook__,
 __weakref__,
 clear,
 copy,
 from_envvar,
 from_object,
 from_pyfile,
 fromkeys,
 get,
 items,
 keys,
 pop,
 popitem,
 root_path,
 setdefault,
 update,
 values]

あと、デフォルト default以外の変数を一括でセットする場合に少しメソッドが準備されてるっぽい、

In [34]: app.config.from_object
Out[34]: <bound method Config.from_object of <Config {DEBUG: False, PREFERRED_URL_SCHEME: http, TRAP_HTTP_EXCEPTIONS: False, SERVER_NAME: None, APPLICATION_ROOT: None, JSON_SORT_KEYS: True, USE_X_SENDFILE: False, PRESERVE_CONTEXT_ON_EXCEPTION: None, PERMANENT_SESSION_LIFETIME: datetime.timedelta(31), SESSION_COOKIE_DOMAIN: None, TRAP_BAD_REQUEST_ERRORS: False, PROPAGATE_EXCEPTIONS: None, SEND_FILE_MAX_AGE_DEFAULT: 43200, JSON_AS_ASCII: True, SECRET_KEY: None, SESSION_COOKIE_SECURE: False, MAX_CONTENT_LENGTH: None, LOGGER_NAME: __main__, SESSION_COOKIE_PATH: None, SESSION_COOKIE_HTTPONLY: True, TESTING: False, SESSION_COOKIE_NAME: session, JSONIFY_PRETTYPRINT_REGULAR: True}>>

In [35]: app.config.from_object()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-35-d00299f68833> in <module>()
----> 1 app.config.from_object()

TypeError: from_object() missing 1 required positional argument: obj

In [36]: app.config.from_envvar()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-36-476db5312dc9> in <module>()
----> 1 app.config.from_envvar()

TypeError: from_envvar() missing 1 required positional argument: variable_name

In [37]: app.config.from_pyfile()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-37-2477e9d956d6> in <module>()
----> 1 app.config.from_pyfile()

TypeError: from_pyfile() missing 1 required positional argument: filename

In [38]: with os.open(aaa.txt, w) as f
  File "<ipython-input-38-89bb3e6c9305>", line 1
    with os.open(aaa.txt, w) as f
                                     ^
SyntaxError: invalid syntax

ふーん、、、
じゃ、ちと、ファイルから読み込みを試す。

In [43]: f = open(aaa.txt, w)

In [44]: f.write(HAGE="hage")
Out[44]: 11

In [45]: f.close()

In [46]: more AAA.txt
HAGE="hage"

In [47]: app.config.from_pyfile(AAA.txt)
Out[47]: True

In [48]: app.config[HAGE]
Out[48]: hage

なるへそ。

APIリファレンス

http://flask.pocoo.org/docs/0.10/api/#flask.Flask.config

シンプルすぎてなんもわからん、、、

例.. 公式から

http://flask.pocoo.org/docs/0.10/tutorial/setup/#step-2-application-setup-code

例.. みげるっちから

blog.miguelgrinberg.com