2013-09-20 11:55:44 -04:00
|
|
|
import logging
|
|
|
|
|
2013-09-30 16:14:48 -04:00
|
|
|
from app import app as application
|
2014-01-31 11:14:07 -05:00
|
|
|
from data.model import db as model_db
|
2013-09-20 11:55:44 -04:00
|
|
|
|
2014-01-30 13:32:06 -05:00
|
|
|
# Initialize logging
|
|
|
|
application.config['LOGGING_CONFIG']()
|
2013-10-25 15:47:34 -04:00
|
|
|
|
2014-01-30 19:48:39 -05:00
|
|
|
# Turn off debug logging for boto
|
|
|
|
logging.getLogger('boto').setLevel(logging.CRITICAL)
|
2013-10-25 15:47:34 -04:00
|
|
|
|
2013-12-30 17:05:27 -05:00
|
|
|
from endpoints.api import api
|
|
|
|
from endpoints.index import index
|
|
|
|
from endpoints.web import web
|
|
|
|
from endpoints.tags import tags
|
|
|
|
from endpoints.registry import registry
|
|
|
|
from endpoints.webhooks import webhooks
|
2014-02-06 13:36:32 -05:00
|
|
|
from endpoints.realtime import realtime
|
2014-02-18 15:50:15 -05:00
|
|
|
from endpoints.callbacks import callback
|
2013-09-20 11:55:44 -04:00
|
|
|
|
2013-10-25 15:47:34 -04:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2013-12-30 17:05:27 -05:00
|
|
|
application.register_blueprint(web)
|
2014-02-18 15:50:15 -05:00
|
|
|
application.register_blueprint(callback, url_prefix='/oauth2')
|
2013-12-30 17:05:27 -05:00
|
|
|
application.register_blueprint(index, url_prefix='/v1')
|
|
|
|
application.register_blueprint(tags, url_prefix='/v1')
|
|
|
|
application.register_blueprint(registry, url_prefix='/v1')
|
|
|
|
application.register_blueprint(api, url_prefix='/api')
|
|
|
|
application.register_blueprint(webhooks, url_prefix='/webhooks')
|
2014-02-06 13:36:32 -05:00
|
|
|
application.register_blueprint(realtime, url_prefix='/realtime')
|
2013-12-30 17:05:27 -05:00
|
|
|
|
2014-01-30 20:57:40 -05:00
|
|
|
|
|
|
|
def close_db(exc):
|
2014-01-31 11:14:07 -05:00
|
|
|
db = model_db
|
2014-01-30 20:57:40 -05:00
|
|
|
if not db.is_closed():
|
|
|
|
logger.debug('Disconnecting from database.')
|
|
|
|
db.close()
|
|
|
|
|
|
|
|
application.teardown_request(close_db)
|
|
|
|
|
|
|
|
|
2013-09-30 16:14:48 -04:00
|
|
|
# Remove this for prod config
|
|
|
|
application.debug = True
|
|
|
|
|
2013-09-30 23:54:12 -04:00
|
|
|
if __name__ == '__main__':
|
2013-10-26 16:03:11 -04:00
|
|
|
application.run(port=5000, debug=True, threaded=True, host='0.0.0.0')
|