2013-09-23 16:37:40 +00:00
|
|
|
import logging
|
2013-10-01 03:54:12 +00:00
|
|
|
import os
|
2013-10-02 04:48:03 +00:00
|
|
|
import stripe
|
2013-09-23 16:37:40 +00:00
|
|
|
|
2013-09-25 16:45:12 +00:00
|
|
|
from flask import Flask
|
2013-09-20 22:38:17 +00:00
|
|
|
from flask.ext.principal import Principal
|
2013-09-25 16:45:12 +00:00
|
|
|
from flask.ext.login import LoginManager
|
2013-09-27 23:29:01 +00:00
|
|
|
from flask.ext.mail import Mail
|
2013-10-03 20:19:01 +00:00
|
|
|
|
2013-11-07 04:21:12 +00:00
|
|
|
from config import (ProductionConfig, DebugConfig, LocalHostedConfig,
|
2014-03-05 00:41:48 +00:00
|
|
|
TestConfig, StagingConfig)
|
2013-10-03 20:19:01 +00:00
|
|
|
from util import analytics
|
|
|
|
|
2013-09-20 15:55:44 +00:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
2013-10-03 20:19:01 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2013-10-01 03:54:12 +00:00
|
|
|
|
2013-10-01 21:23:29 +00:00
|
|
|
stack = os.environ.get('STACK', '').strip().lower()
|
|
|
|
if stack.startswith('prod'):
|
2013-10-03 20:19:01 +00:00
|
|
|
logger.info('Running with production config.')
|
2013-10-01 21:23:29 +00:00
|
|
|
config = ProductionConfig()
|
2014-03-05 00:40:29 +00:00
|
|
|
elif stack.startswith('staging'):
|
|
|
|
logger.info('Running with staging config on production data.')
|
|
|
|
config = StagingConfig()
|
2013-10-01 21:23:29 +00:00
|
|
|
elif stack.startswith('localhosted'):
|
2013-10-03 20:19:01 +00:00
|
|
|
logger.info('Running with debug config on production data.')
|
2013-10-01 21:23:29 +00:00
|
|
|
config = LocalHostedConfig()
|
2013-11-07 04:21:12 +00:00
|
|
|
elif stack.startswith('test'):
|
|
|
|
logger.info('Running with test config on ephemeral data.')
|
|
|
|
config = TestConfig()
|
2013-10-01 21:23:29 +00:00
|
|
|
else:
|
2013-10-03 20:19:01 +00:00
|
|
|
logger.info('Running with debug config.')
|
2013-10-01 21:23:29 +00:00
|
|
|
config = DebugConfig()
|
|
|
|
|
|
|
|
app.config.from_object(config)
|
2013-09-27 23:29:01 +00:00
|
|
|
|
2014-03-17 16:01:13 +00:00
|
|
|
Principal(app, use_sessions=False)
|
2013-09-20 22:38:17 +00:00
|
|
|
|
2013-09-23 16:37:40 +00:00
|
|
|
login_manager = LoginManager()
|
|
|
|
login_manager.init_app(app)
|
2013-09-27 23:29:01 +00:00
|
|
|
|
|
|
|
mail = Mail()
|
|
|
|
mail.init_app(app)
|
2013-10-02 04:48:03 +00:00
|
|
|
|
2013-11-07 04:21:12 +00:00
|
|
|
stripe.api_key = app.config.get('STRIPE_SECRET_KEY', None)
|
2013-10-03 20:19:01 +00:00
|
|
|
|
2013-11-07 04:21:12 +00:00
|
|
|
mixpanel = app.config['ANALYTICS'].init_app(app)
|