Created
June 2, 2022 10:04
-
-
Save twyle/c2e92728d0eba6444fb1bb25373a567a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""This module has methods that are used in the other modules in this package.""" | |
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('api.config.ProductionConfig') | |
elif os.environ['FLASK_ENV'] == 'development': # pragma: no cover | |
app.config.from_object('api.config.DevelopmentConfig') | |
elif os.environ['FLASK_ENV'] == 'test': | |
app.config.from_object('api.config.TestingConfig') | |
return os.environ['FLASK_ENV'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment