-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.py
More file actions
30 lines (26 loc) · 860 Bytes
/
helpers.py
File metadata and controls
30 lines (26 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
import os
from dotenv import load_dotenv
load_dotenv()
def set_flask_environment(app) -> str:
"""Set the flask development environment.
Parameters
----------
app: flask.Flask
The flask application object
Raises
------
KeyError
If the FLASK_ENV environment variable is not set.
Returns
-------
str:
Flask operating environment i.e development
"""
if os.environ['FLASK_ENV'] == 'production': # pragma: no cover
app.config.from_object('config.ProductionConfig')
elif os.environ['FLASK_ENV'] == 'development': # pragma: no cover
app.config.from_object('config.DevelopmentConfig')
elif os.environ['FLASK_ENV'] == 'test':
app.config.from_object('config.TestingConfig')
return os.environ['FLASK_ENV']