import logging import os import stripe import json from flask import Flask from flask.ext.principal import Principal from flask.ext.login import LoginManager from flask.ext.mail import Mail import features from storage import Storage from config import DefaultConfig from data.userfiles import Userfiles from util.analytics import Analytics app = Flask(__name__) logger = logging.getLogger(__name__) logger.debug('Loading default config.') app.config.from_object(DefaultConfig()) if 'QUAY_CONFIG_FILE' in os.environ: config_filename = os.environ['QUAY_CONFIG_FILE'] logger.debug('Applying config file: %s', config_filename) app.config.from_pyfile(config_filename) overrides = json.loads(os.environ.get('QUAY_CONFIG', '{}')) logger.debug('Applying %s config overrides.', len(overrides)) app.config.from_object(overrides) features.import_features(app.config) print "Billing: %s" % features.BILLING Principal(app, use_sessions=False) login_manager = LoginManager() login_manager.init_app(app) mail = Mail() mail.init_app(app) storage = Storage() storage.init_app(app) userfiles = Userfiles() userfiles.init_app(app) stripe.api_key = app.config.get('STRIPE_SECRET_KEY', None) analytics = Analytics() analytics.init_app(app)