Files @ 52127f437376
Branch filter:

Location: C3L/C3L-Membership-Online-Form/c3l_membership/__init__.py - annotation

Dennis Fink
Split up membership plans into more fields.

Student and starving are now options that can be selected additionally to the
regular or supporting membership.
import json
import os.path

from flask import Flask
from flask_pure import Pure
from flask_qrcode import QRcode

config_file = os.path.abspath("config.json")

pure = Pure()
qrcode = QRcode()


def create_app():

    app = Flask(__name__)

    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

    try:
        app.config.from_json(config_file)
    except FileNotFoundError:
        pass

    app.config["PURECSS_RESPONSIVE_GRIDS"] = True
    app.config["PURECSS_USE_CDN"] = False
    app.config["PURECSS_USE_MINIFIED"] = True
    pure.init_app(app)

    qrcode.init_app(app)

    app.config["SECRET_KEY"] = "foobar"

    from .views import root_page

    app.register_blueprint(root_page)

    return app


app = create_app()