diff --git a/ennstatus/__init__.py b/ennstatus/__init__.py --- a/ennstatus/__init__.py +++ b/ennstatus/__init__.py @@ -1,4 +1,6 @@ import os.path +import json + from flask import Flask, render_template from flask.ext.bootstrap import Bootstrap @@ -11,13 +13,32 @@ import gnupg bootstrap = Bootstrap() compress = Compress() +config_file = os.path.abspath('config.json') + def create_app(): app = Flask(__name__) - config_file = os.path.abspath('config.py') - app.config.from_pyfile(config_file) + if not hasattr(app.config, 'from_json'): + def from_json(file, silent=True): + try: + with open(file, encoding='utf-8') as json_file: + obj = json.load(json_file) + except IOError: + if silent: + return False + raise + + for key in obj: + if key.isupper(): + app.config[key] = obj[key] + + return True + + app.config.from_json = from_json + + app.config.from_json(config_file) app.wsgi_app = ProxyFix(app.wsgi_app)