Make it possible to load configuration from a Python file #3

Merged
gergely merged 1 commits from configuration into master 2018-06-29 07:06:44 +00:00
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'