def app(request): """The Flask API (scope = Session).""" config.DB_NAME = DB_NAME DATABASE_URI = config.DATABASE_URI.format(**config.__dict__) if not database_exists(DATABASE_URI): create_database(DATABASE_URI) print "Test Database: %s" % DATABASE_URI # Config the app _app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URI _app.config["SQLALCHEMY_ECHO"] = True # Toggle SQL Alchemy output _app.config["DEBUG"] = True _app.config["TESTING"] = True # Establish an application context before running the tests. ctx = _app.app_context() ctx.push() # Initialize a null cache cache.config = {} cache.init_app(_app) def teardown(): ctx.pop() request.addfinalizer(teardown) return _app
def create_app( settings = 'server.settings.Dev' ): MAIN.config.from_object( settings ) # Initialize db/cache with app db.init_app( MAIN ) cache.init_app( MAIN ) # Register apis MAIN.register_blueprint( test_api, url_prefix='/test' ) return MAIN
def create_app(settings='server.settings.Dev'): MAIN.config.from_object(settings) # Initialize db/cache with app db.init_app(MAIN) cache.init_app(MAIN) # Register apis MAIN.register_blueprint(analyzer_api, url_prefix='/api') MAIN.register_blueprint(misc_api, url_prefix='/api') return MAIN
def create_app( settings='server.settings.Dev' ): MAIN.config.from_object( settings ) # Initialize db/cache with app # db.init_app( MAIN ) cache.init_app( MAIN ) mongo.init_app( MAIN ) # Register apis MAIN.register_blueprint( findings_api, url_prefix='/api/finding' ) MAIN.register_blueprint( explanations_api, url_prefix='/api/explanation' ) MAIN.register_blueprint( admin_api, url_prefix='/admin' ) return MAIN
def create_app(): app = Flask( __name__, static_url_path="/resources", ) app.config.update(DEBUG=True) app.config.update(SECRET_KEY="ThisIsAMagicKey") app.logger.info("starting imdb venn diagram") CORS(app) cache.init_app(app, config={ "CACHE_TYPE": "simple", "CACHE_DEFAULT_TIMEOUT": 860_000 }) app.register_blueprint(page) app.register_blueprint(api) return app
import logging import sys from server import config from server.database import db from server.cache import cache, get_view_func from server.web import app logger = logging.getLogger(__name__) if __name__ == "__main__": db.init_app(app) cache.init_app(app) logger = logging.getLogger("server") sqla_logger = logging.getLogger("sqlalchemy") handler = logging.StreamHandler(stream=sys.stdout) logger.addHandler(handler) logger.setLevel(logging.INFO) sqla_logger.addHandler(handler) sqla_logger.setLevel(logging.DEBUG) items = [(key, value) for key, value in config.__dict__.iteritems() if key.startswith("APP_") or key.startswith("DB_")] for key, value in sorted(items, key=lambda t: t[0]): logger.info("{:>20}: {}".format(key, str(value))) # And off we go! app.run(port=config.APP_PORT, host=config.APP_HOST, debug=config.APP_DEBUG)