Load configuration based on the ENV environment variable

This commit is contained in:
Gergely Polonkai 2018-06-28 08:31:11 +02:00
parent bed00e45f6
commit a0d630d9bf
3 changed files with 9 additions and 2 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
__pycache__/
__pycache__/

View File

@ -14,13 +14,18 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
from flask import Flask, render_template
class CalendarSocialApp(Flask):
def __init__(self, name):
def __init__(self, name, config=None):
Flask.__init__(self, name)
config_name = os.environ.get('ENV', config or 'dev')
self.config.from_pyfile(f'config_{config_name}.py', True)
app = CalendarSocialApp(__name__)

2
app/config_dev.py Normal file
View File

@ -0,0 +1,2 @@
DEBUG = True
ENV = 'dev'