Beispiel #1
0
def create_app():
  app = Flask(__name__)
  app.secret_key = 'not a secret key'

  # FIXME duplicated in database.py
  if is_production():
    app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:jackathon@localhost/watchtower'
  elif is_scan():
    #app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:jackathon@75.101.157.206/watchtower'
    # TODO assumes static private ip
    app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:jackathon@10.73.181.115/watchtower'
  else:
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////var/watchtower/watchtower.db'
  db.init_app(app)
  # admin setup
  admin = Admin(app)
  admin.add_view(ModelView(Page, db.session))
  class MyModelView(ModelView):
    def __init__(self, model, session, name=None, category=None, endpoint=None, url=None, **kwargs):
      for k, v in kwargs.iteritems():
          setattr(self, k, v)

      super(MyModelView, self).__init__(model, session, name=name, category=category, endpoint=endpoint, url=url)

    def is_accessible(self):
      # Logic
      return True
  #admin.add_view(MyModelView(Version, db.session, column_list=['id', 'foreign_key']))
  admin.add_view(ModelView(Version, db.session,))
  admin.add_view(ModelView(Element, db.session,))
  admin.add_view(ModelView(User, db.session,))
  return app
Beispiel #2
0
def create_app():
    app = Flask(__name__)
    app.secret_key = 'super~~~~~~~~~~~~'

    # url
    app.register_blueprint(welcome_page)
    app.register_blueprint(auth_page)

    # db
    if socket.gethostname() == 'lihaichuangdeMac-mini.local':
        print(1)
        app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://sctlee:123456@192.168.99.100:3306/singledog'
    else:
        print(2)
        conn_string = 'mysql+pymysql://%s:%s@%s:%s/%s' % (os.getenv('MYSQL_USERNAME'), os.getenv('MYSQL_PASSWORD'),\
                      os.getenv('MYSQL_PORT_3306_TCP_ADDR'), os.getenv('MYSQL_PORT_3306_TCP_PORT'),\
                      os.getenv('MYSQL_INSTANCE_NAME'))
        print(conn_string)
        app.config['SQLALCHEMY_DATABASE_URI'] = conn_string

    db.init_app(app)

    from models import User
    db.create_all(app=app)

    # login manager
    login_manager.init_app(app)

    @app.before_request
    def before_request():
        g.user = current_user

    return app
def create_app():
    app = Flask(__name__)
    if is_mac():
        # load config
        app.config['SQLALCHEMY_DATABASE_URI'] = config.db_path
    else:
        app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')

    init_extensions(app)
    init_views(app)
    return app
Beispiel #4
0
def create_app(debug=True):
    """Create an application."""
    app = Flask(__name__)
    app.debug = debug
    app.config['SECRET_KEY'] = 'gjr39dkjn344_!67#'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://anthony:dx9Vzxq6fr@localhost/vpnp'
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)
    db.init_app(app=app)
    socketio.init_app(app)
    return app
def test_db(request):
    """Test database backend."""
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
        'SQLALCHEMY_DATABASE_URI', 'sqlite://'
    )
    FlaskCLI(app)
    InvenioDB(app)
    FlaskOAuth(app)
    InvenioOAuthClient(app)

    def teardown():
        with app.app_context():
            db.drop_all()

    request.addfinalizer(teardown)

    with app.app_context():
        if str(db.engine.url) != 'sqlite://' and \
           not database_exists(str(db.engine.url)):
                create_database(str(db.engine.url))
        db.create_all()
        tables = list(filter(lambda table: table.startswith('oauthclient'),
                             db.metadata.tables.keys()))
        assert len(tables) == 3
Beispiel #6
0
def create_app(db_dialect):

    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = db_dialect

    db.init_app(app)

    # /app
    from .application import application as application_blueprint
    app.register_blueprint(application_blueprint, url_prefix='/app')

    # /public
    from .public import public as public_blueprint
    app.register_blueprint(public_blueprint, url_prefix='/public')

    # /
    from .index import index as index_blueprint
    app.register_blueprint(index_blueprint, url_prefix='/')

    # /traces
    from .traces import traces as traces_blueprint
    app.register_blueprint(traces_blueprint, url_prefix='/traces')

    # /aggregate
    from .aggregate import aggregate as aggregate_blueprint
    app.register_blueprint(aggregate_blueprint, url_prefix='/aggregate')

    # /api
    from .api import api as api_blueprint
    app.register_blueprint(api_blueprint, url_prefix='/api')

    return app
Beispiel #7
0
def init_app():
    """
    Factory function to init Flask applictaion.
    """
    # Init Flask application and necessary extensions
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'

    admin = Admin(app)
    db = SQLAlchemy(app)

    # Add url rules to application
    views = LazyViews(app)
    views.add('/', 'views.home')
    views.add('/db', 'views.database_page')
    views.add('/error', 'views.server_error')
    views.add('/page/<int:page_id>', 'views.page', endpoint='flatpage')
    views.add('/page/<int:page_id>/cls',
              'views.PageView',
              endpoint='flatpage_cls')
    views.add_admin('admin.AdminView',
                    endpoint='app_admin',
                    name='App View')
    views.add_error(404, 'views.error')
    views.add_error(500, 'views.error')
    views.add_static('/favicon.ico',
                     defaults={'filename': 'img/favicon.ico'},
                     endpoint='favicon')

    # Register test blueprint
    app.register_blueprint(test_blueprint, url_prefix='/test')

    return (app, admin, db)
Beispiel #8
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(Conf)
    print('create_app')
    # redis
    app.redis_store = redis.Redis(host=app.config["REDIS_HOST"], port=app.config["REDIS_PORT"], decode_responses=True)

    app.config['SQLALCHEMY_DATABASE_URI'] = Conf.MYSQL_INFO
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    # Mail
    app.config['MAIL_SERVER'] = Conf.MAIL_SERVER
    app.config['MAIL_PORT'] = Conf.MAIL_PORT
    app.config['MAIL_USE_TLS'] = Conf.MAIL_USE_TLS


    # 蓝图
    from app.admin import admin_api as admin_api_blueprint
    app.register_blueprint(admin_api_blueprint, url_prefix='/api/admin')

    from app.api.v1_0_0 import api_v1_0_0 as api_1_0_blueprint
    app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1.0.0')

    from app.api.v1_0_1 import api_v1_0_1 as api_1_1_blueprint
    app.register_blueprint(api_1_1_blueprint, url_prefix='/api/v1.0.1')

    # init
    db.init_app(app)
    return app
def create_app(config_name):
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
    app.config.from_object(config[config_name])
    app.config['SECRET_KEY'] = 'you-will-never-guess'
    config[config_name].init_app(app)

    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .admin import admin as admin_blueprint
    app.register_blueprint(admin_blueprint, url_prefix='/departments')

    from .issues import issues as issues_blueprint
    app.register_blueprint(issues_blueprint, url_prefix='/issues')

    @app.errorhandler(404)
    def not_found(error):
        return render_template('404.html', title="404 Error"), 404

    @app.errorhandler(403)
    def forbidden(error):
        return render_template('403.html', title="403 Error"), 403

    # with app.app_context():
    #     db.create_all()

    return app
Beispiel #10
0
def create_app():
    app = Flask(__name__)
    # Set crucial variables
    app.secret_key = os.environ['SECRET_KEY']
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']

    # Set non crucial variables
    app.config['MAILGUN_API_URL'] = os.environ.get('MAILGUN_API_URL', '')
    app.config['MAILGUN_API_KEY'] = os.environ.get('MAILGUN_API_KEY', '')
    app.config['MAILGUN_TEST_OPTION'] = True if os.environ.get('MAILGUN_TEST_OPTION', 'True') == 'True' else False
    app.config['NOTIFICATION_EMAIL'] = os.environ.get('MAILGUN_SMTP_LOGIN', '')
    app.config['REDDIT_PASSWORD'] = os.environ.get('WPC_REDDIT_PASSWORD', '')
    app.config['REDDIT_USERNAME'] = os.environ.get('WPC_REDDIT_USERNAME', '')
    app.config['YOUTUBE_KEY'] = os.environ.get('WPC_YOUTUBE_KEY', '')
    app.config['GA_TRACKING_CODE'] = os.environ.get('GA_TRACKING_CODE', '')
    app.config['REDDIT_API_ID'] = os.environ.get('WPC_APP_ID', '')
    app.config['REDDIT_API_SECRET'] = os.environ.get('WPC_APP_SECRET', '')
    app.config['RTMP_LOGIN'] = os.environ.get('RTMP_LOGIN', '')
    app.config['RTMP_PASSWORD'] = os.environ.get('RTMP_PASSWORD', '')
    app.config['RTMP_SERVER'] = os.environ.get('RTMP_SERVER', '127.0.0.1')
    app.config['SERVER_NAME'] = os.environ.get('SERVER_NAME', '')

    app.config['REDDIT_WEB_APP_USER_AGENT'] = "/r/WatchPeopleCode web app(main contact: /u/godlikesme)"
    app.config['REDDIT_BOT_USER_AGENT'] = "/r/WatchPeopleCode flairs&streams bot (main contact: /u/godlikesme)"

    Bootstrap(app)
    loggers_and_levels = [(app.logger, logging.INFO),
                          (logging.getLogger('sqlalchemy'), logging.WARNING),
                          (logging.getLogger('apscheduler.scheduler'), logging.INFO)]
    setup_logging(loggers_and_levels, logentries_id=os.environ.get('LOGENTRIES_ID', None))

    app.logger.info("App created!")

    return app
Beispiel #11
0
def init_app():
    db_path = 'db1.sqlite'

    # 初始化并配置 flask
    app = Flask(__name__)
    # 这一行 加了就没 warning
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    # 设置你的加密 key
    app.secret_key = 'TODO fixme'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{}'.format(db_path)
    # 初始化 db
    db.init_app(app)
    db.app = app

    # 必须在函数中 import 蓝图
    # 否则循环引用(因为蓝图中 import 了 model, model 引用了这个文件里面目的 db)
    # from .auth import blue as auth
    from .controllers import main as controllers
    from .api import main as api1

    # 注册蓝图
    # app.register_blueprint(auth)
    app.register_blueprint(controllers)
    app.register_blueprint(api1, url_prefix='/api')

    # 把 app 引用返回
    return app
Beispiel #12
0
def generate_app():
    app = Flask(__name__)
    app.config['PROPAGATE_EXCEPTIONS'] = True
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DB_URI']
    with open("/data/secret_key") as fd:
        app.config['SECRET_KEY'] = fd.read().strip()
    return app
Beispiel #13
0
def create_app():
    global app, db, es

    app = Flask(__name__, instance_relative_config=True)

    app.config.from_object('annotator.default_settings')
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config['SQLALCHEMY_DATABASE_URI'] % app.instance_path

    app.config.from_pyfile('annotator.cfg', silent=True)
    app.config.from_envvar('ANNOTATOR_CONFIG', silent=True)

    # Configure database
    db.init_app(app)

    # Configure ES
    from . import model
    es = pyes.ES(app.config['ELASTICSEARCH_HOST'])
    model.annotation.configure(es, app.config)

    # Mount controllers
    from annotator import store, user, home

    if app.config['MOUNT_STORE']:
        app.register_blueprint(store.store, url_prefix=app.config['MOUNT_STORE'])
    if app.config['MOUNT_USER']:
        app.register_blueprint(user.user, url_prefix=app.config['MOUNT_USER'])
    if app.config['MOUNT_HOME']:
        app.register_blueprint(home.home, url_prefix=app.config['MOUNT_HOME'])

    @app.before_request
    def before_request():
        g.user = user.get_current_user()

    return app
def create_app(settings=None):
    """
    Creates a flask application.

    @param settings: Settings override object.
    @return: The flask application.
    """
    app = Flask(__name__)

    if settings:
        app.config.from_object(settings)
    else:
        args = _generate_args()
        profile = args.pop('profile')
        app.config['DEBUG'] = args.pop('debug')
        config_file = _load_config_file()
        database_uri = _load_database()
        _config_from_config_profile(config_file, profile, app)
        app.config['SQLALCHEMY_DATABASE_URI'] = database_uri

    DB.init_app(app)

    default_controller = __import__(
        'ec2stack.controllers.' + 'default', None, None, 'DEFAULT'
    )
    default_controller = getattr(default_controller, 'DEFAULT')
    app.register_blueprint(default_controller)

    return app
def create_app(config_name):
    app = Flask(__name__)



    # Creating the app configurations
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://hzdjuymgaykvle:4079958f7180f18102b516a8f427e0794e8f22080047c631e44d39f929359d5a@ec2-54-235-240-126.compute-1.amazonaws.com:5432/di59qlb6lan20'

   # Creating the app configurations

    app.config.from_object(config_options[config_name])
    config_options[config_name].init_app(app)

    # Initializing flask extensions
    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)

    # Registering the blueprint
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    
    return app
Beispiel #16
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \
        os.path.join(os.path.dirname(os.path.abspath(__file__)), 'flaskr.db')
    configure_app(app)
    return app
Beispiel #17
0
def create_app(object_name, env, dbcon):
    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config['ENV'] = env
    app.config['SQLALCHEMY_DATABASE_URI'] = dbcon

    @app.errorhandler(500)
    def error_handler_500(e):
        if app.config['APP_SERVER'] != 'DEV':
            return render_template('500.html'), 500

    @app.errorhandler(404)
    def error_handler_404(e):
        if app.config['APP_SERVER'] != 'DEV':
            return render_template('404.html'), 404

    @app.route('/robots.txt')
    @app.route('/sitemap.xml')
    def static_from_root():
        return send_from_directory(app.static_folder, request.path[1:])

    @app.before_request
    def before_request():
        g.app_server = app.config['APP_SERVER']
        if 'db_engine' not in 'g':
            g.db_engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])

    # register our blueprints
    from app.blueprints import main
    app.register_blueprint(main)

    return app
Beispiel #18
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:root1234@knowledgebase2018.cd3pupo3w3sq.ap-southeast-1.rds.amazonaws.com/knowledgebase'

    db.init_app(app)

    print("App created")
    csrf.init_app(app)
    from knowledge import knowledge as knowledge_blueprint

    # login_manager.session_protection = "strong"
    login_manager.init_app(app)
    login_manager.login_view = 'knowledge.login'


    app.register_blueprint(knowledge_blueprint)

    moment.init_app(app)
    misaka.init_app(app)

    bootstrap.init_app(app)

    jsglue = JSGlue(app)
    Markdown(app)

    return app
Beispiel #19
0
def create_app(db_name=None, testing=False):
    """
    Create the Flask app object after configuring it.

    Keyword arguments:
        db_name -- Database name
        testing -- Enable/Disable testing mode

    Return value:
        app -- Flask application object

    """
    try:
        app = Flask(__name__)
        app.config.from_object(settings)
    except:
        print "Settings file is missing, trying with env config..."
        app.config.from_envvar('MNEMOSYNE_SETTINGS', silent=False)

    if db_name:
        app.config['SQLALCHEMY_DATABASE_URI'] = db_name

    db.init_app(app)

    app.register_blueprint(frontend)

    return app
def create_schema(uri, pkg_name):
    app = Flask('schema generator')
    app.config['SQLALCHEMY_DATABASE_URI'] = uri
    list(load_all_modules(pkg_name))
    db.init_app(app)
    with app.app_context():
        db.create_all()
    def setUp(self):
        _ENGINES.clear()
        _BASES.clear()
        app = Flask(__name__)
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.sqlite'
        db.init_app(app)
        self.app = app
        with app.app_context():
            db.create_all(app=app)
            self.db = db
            self.user = User(username='user', password='password',
                             database_uri='sqlite:///:memory:')
            db.session.add(self.user)
            try:
                db.session.commit()
            except IntegrityError:
                db.session.rollback()
        self.engine = create_engine('sqlite:///:memory:')
        self.base = declarative_base()

        class Blah(self.base):
            __tablename__ = 'blah'
            id = Column(Integer, primary_key=True)

        self.model = Blah
        self.base.metadata.create_all(self.engine)
        _ENGINES['sqlite:///:memory:'] = self.engine
Beispiel #22
0
def create_app():
  options = {
    'port' : 0,
    'unitTesting': False
  }
  WebConfig.config(options)

  b = Borg()
  app = Flask(__name__)
  app.config['DEBUG'] = True
  app.config['SECRET_KEY'] = b.secretKey
  app.config['SECURITY_PASSWORD_HASH'] = b.passwordHash
  app.config['SECURITY_PASSWORD_SALT'] = b.passwordSalt
  app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://' + b.auth_dbUser + ':' + b.auth_dbPasswd + '@' + b.auth_dbHost + '/' + b.auth_dbName
  b.logger.setLevel(b.logLevel)
  b.logger.debug('Error handlers: {0}'.format(app.error_handler_spec))
  app.secret_key = os.urandom(24)
  logger = logging.getLogger('werkzeug')
  logger.setLevel(b.logLevel)
  enable_debug = b.logLevel = logging.DEBUG

  cors = CORS(app)
  db.init_app(app)
  user_datastore = SQLAlchemyUserDatastore(db,User, Role)
  security = Security(app, user_datastore)

  from main import main as main_blueprint 
  app.register_blueprint(main_blueprint)

  with app.app_context():
    db.create_all()

  return app
Beispiel #23
0
def create_app(settings=None):
    """
    Creates a flask application.

    @param settings: Settings override object.
    @return: The flask application.
    """
    app = Flask(__name__)

    if settings:
        app.config.from_object(settings)
    else:
        config_file = _load_config_file()
        app.config.from_pyfile(config_file)
        database_uri = _load_database()
        app.config['SQLALCHEMY_DATABASE_URI'] = database_uri

    _valid_config_file(app)
    DB.init_app(app)

    default_controller = __import__(
        'ec2stack.controllers.' + 'default', None, None, 'DEFAULT'
    )
    default_controller = getattr(default_controller, 'DEFAULT')
    app.register_blueprint(default_controller)

    return app
Beispiel #24
0
def create_app(name):
	# create our little application :)
	app = Flask(name)
	app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
	app.config.from_object(__name__)
	app.config.from_envvar('FLASKR_SETTINGS', silent=True)
	return app
def create_app(config_name):
    application = Flask(__name__)
    application.config['DM_ENVIRONMENT'] = config_name

    init_app(
        application,
        configs[config_name],
        db=db,
        search_api_client=search_api_client,
        error_handlers=api_error_handlers,
    )

    if not application.config['DM_API_AUTH_TOKENS']:
        raise Exception("No DM_API_AUTH_TOKENS provided")

    if application.config['VCAP_SERVICES']:
        cf_services = json.loads(application.config['VCAP_SERVICES'])
        application.config['SQLALCHEMY_DATABASE_URI'] = cf_services['postgres'][0]['credentials']['uri']

    from .metrics import metrics as metrics_blueprint, gds_metrics
    from .main import main as main_blueprint
    from .status import status as status_blueprint
    from .callbacks import callbacks as callbacks_blueprint

    application.register_blueprint(metrics_blueprint)
    application.register_blueprint(main_blueprint)
    application.register_blueprint(callbacks_blueprint, url_prefix='/callbacks')
    application.register_blueprint(status_blueprint)

    gds_metrics.init_app(application)

    return application
Beispiel #26
0
def create_app():
    app = Flask(__name__)
    app.config['DEBUG'] = True
    app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:////Users/olivergoodman/Documents/github/app-blueprint/my_app/personal.db"
    db.init_app(app)    
    app.register_blueprint(hello, url_prefix='')
    return app 
Beispiel #27
0
    def test_flask(self):
        app = Flask(__name__)
        db = SQLAlchemy(app)
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'

        class Cities(db.Model):
            __tablename__ = 'users'

            id = Column(Integer, primary_key=True)
            name = Column(String)
            population = Column(Integer)

            def __init__(self, name, population):
                self.name = name
                self.population = population
                
        app.config['TESTING'] = True
        app = app.test_client()
        db.create_all()

        city = Cities("Cordoba", 1000000)
        db.session.add(city)
        city = Cities("Rafaela", 99000)
        db.session.add(city)
        db.session.commit()

        query_string = '{ "sort": { "population" : "desc" } }'
        results = elastic_query(Cities, query_string)
        assert(results[0].name == 'Cordoba')
Beispiel #28
0
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///intent.db'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    babel = Babel(app)
    db.init_app(app)
    return app
def test_flask_sqlalchemy():
    from flask.ext.sqlalchemy import SQLAlchemy as FlaskSQLAlchemy

    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'
    db = FlaskSQLAlchemy(app)

    class UserMixin(object):
        email = db.Column(db.Unicode(300))

        def __init__(self, login, email):
            self.login = login
            self.email = email
            self.password = 'foobar'

    class RoleMixin(object):
        description = db.Column(db.UnicodeText)

    auth = authcode.Auth(SECRET_KEY, db=db, UserMixin=UserMixin, RoleMixin=RoleMixin)
    authcode.setup_for_flask(auth, app)
    User = auth.User

    db.create_all()
    user = User(u'meh', u'text@example.com')
    db.session.add(user)
    db.session.commit()

    assert user.login == u'meh'
    assert user.email == u'text@example.com'
    assert hasattr(user, 'password')
    assert hasattr(user, 'last_sign_in')
    assert repr(user) == '<User meh>'
Beispiel #30
0
    def setUp(self):
        """Creates the Flask application and the APIManager."""
        # create the Flask application
        app = Flask(__name__)
        app.config['DEBUG'] = True
        app.config['TESTING'] = True
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        app.logger.disabled = True
        self.flaskapp = app

        # create the test client
        self.app = app.test_client()

        # Ensure that all requests have Content-Type set to "application/json"
        # unless otherwise specified.
        for methodname in ('get', 'put', 'patch', 'post', 'delete'):
            # Create a decorator for the test client request methods that adds
            # a JSON Content-Type by default if none is specified.
            def set_content_type(func):
                def new_func(*args, **kw):
                    if 'content_type' not in kw:
                        kw['content_type'] = 'application/json'
                    return func(*args, **kw)
                return new_func
            # Decorate the original test client request method.
            old_method = getattr(self.app, methodname)
            setattr(self.app, methodname, set_content_type(old_method))