Add Support for FLASK_ENV (#2570)

This introduces environments to Flask
This commit is contained in:
Armin Ronacher 2018-01-06 17:07:56 +01:00 committed by GitHub
parent 60eecb547d
commit 2433522d29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 151 additions and 71 deletions

View file

@ -46,10 +46,20 @@ _os_alt_seps = list(sep for sep in [os.path.sep, os.path.altsep]
if sep not in (None, '/'))
def get_debug_flag(default=None):
def get_env():
val = os.environ.get('FLASK_ENV')
if not val:
val = 'production'
return val
def get_debug_flag():
val = os.environ.get('FLASK_DEBUG')
if not val:
return default
env = get_env()
if env == 'development':
return True
return False
return val.lower() not in ('0', 'false', 'no')