forked from orbit-oss/flask
Add Support for FLASK_ENV (#2570)
This introduces environments to Flask
This commit is contained in:
parent
60eecb547d
commit
2433522d29
10 changed files with 151 additions and 71 deletions
|
|
@ -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')
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue