Python app 模块,create_app() 实例源码

我们从Python开源项目中,提取了以下40个代码示例,用于说明如何使用app.create_app()

项目:backend    作者:gitplaylist    | 项目源码 | 文件源码
def before_all(context):
    """Create the context bag."""
    # Change the configuration on the fly
    os.environ['ENV'] = 'testing'

    # Import this now because the environment variable
    # should be changed before this happens.

    context.app = create_app()

    # Create all the tables in memory.
    with context.app.app_context():
        db.create_all()

    # Create the test client.
    context.client = context.app.test_client()
项目:dpr-api    作者:oki-archive    | 项目源码 | 文件源码
def setUp(self):
        self.publisher = 'demo'
        self.package = 'demo-package'
        self.app = create_app()
        self.client = self.app.test_client()
        with self.app.app_context():
            db.drop_all()
            db.create_all()
            descriptor = json.loads(open('fixtures/datapackage.json').read())
            readme = open('fixtures/README.md').read()
            publisher = Publisher(name=self.publisher)
            package = Package(name=self.package,descriptor=descriptor, readme=readme)

            publisher.packages.append(package)
            db.session.add(publisher)
            db.session.commit()
项目:dpr-api    作者:oki-archive    | 项目源码 | 文件源码
def setUp(self):
        self.publisher = 'demo'
        self.package = 'demo-package'
        self.app = create_app()
        self.app.app_context().push()
        with self.app.test_request_context():
            db.drop_all()
            db.create_all()
            user = User(id=11,
                        name=self.publisher,
                        secret='supersecret')
            publisher = Publisher(name=self.publisher)
            association = PublisherUser(role=UserRoleEnum.owner)
            association.publisher = publisher
            user.publishers.append(association)

            db.session.add(user)
            db.session.commit()
项目:dpr-api    作者:oki-archive    | 项目源码 | 文件源码
def setUp(self):
        self.publisher = 'test_publisher'
        self.package1 = 'test_package1'
        self.package2 = 'test_package2'
        self.app = create_app()
        self.client = self.app.test_client()
        with self.app.app_context():
            db.drop_all()
            db.create_all()
            publisher = Publisher(name=self.publisher)
            metadata1 = Package(name=self.package1)
            metadata2 = Package(name=self.package2)
            publisher.packages.append(metadata1)
            publisher.packages.append(metadata2)
            db.session.add(publisher)
            db.session.commit()
项目:dpr-api    作者:oki-archive    | 项目源码 | 文件源码
def setUp(self):
        self.publisher = 'demo'
        self.app = create_app()
        self.app.app_context().push()
        with self.app.test_request_context():
            db.drop_all()
            db.create_all()

            user = User(name=self.publisher)
            publisher = Publisher(name=self.publisher)
            association = PublisherUser(role=UserRoleEnum.owner)
            association.publisher = publisher
            user.publishers.append(association)

            db.session.add(user)
            db.session.commit()
项目:dpr-api    作者:oki-archive    | 项目源码 | 文件源码
def setUp(self):
        self.user_name = 'demo'
        self.app = create_app()
        self.app.app_context().push()
        with self.app.test_request_context():
            db.drop_all()
            db.create_all()

            user = User(id=11,
                        name=self.user_name,
                        secret='supersecret')
            publisher = Publisher(name='test_pub_id')
            association = PublisherUser(role=UserRoleEnum.owner)
            association.publisher = publisher
            user.publishers.append(association)

            db.session.add(user)
            db.session.commit()
项目:circleci-demo-python-flask    作者:CircleCI-Public    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client(use_cookies=True)
项目:circleci-demo-python-flask    作者:CircleCI-Public    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client()
项目:circleci-demo-python-flask    作者:CircleCI-Public    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
项目:circleci-demo-python-flask    作者:CircleCI-Public    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
项目:do-portal    作者:certeu    | 项目源码 | 文件源码
def create_cli_app(info):
    return create_app(os.getenv('DO_CONFIG') or 'default')
项目:do-portal    作者:certeu    | 项目源码 | 文件源码
def app(request):
    """Build an application"""
    app = create_app('testing')
    ctx = app.app_context()
    ctx.push()

    request.addfinalizer(ctx.pop)
    return app
项目:FMBlog    作者:vc12345679    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
项目:pep8speaks    作者:OrkoHunter    | 项目源码 | 文件源码
def app():
    # app = Flask(__name__)
    app = create_app()
    return app
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client(use_cookies=True)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client()
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
项目:GWMMS    作者:lvhuiyang    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
项目:Plog    作者:thundernet8    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('development')  # TODO add test config
        self.app_context = self.app.app_context()
        self.app_context.push()
项目:Plog    作者:thundernet8    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('development')  # TODO add test config
        self.app_context = self.app.app_context()
        self.app_context.push()
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()

    # ?????
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.context = self.app.app_context()
        self.context.push()
        db.create_all()
        Role.insert_roles()
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
项目:unicorn-remote    作者:njbbaer    | 项目源码 | 文件源码
def setUp(self):
        app = create_app()
        self.app = app.test_client()
项目:smart-iiot    作者:quanpower    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client(use_cookies=True)
项目:smart-iiot    作者:quanpower    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client()
项目:smart-iiot    作者:quanpower    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
项目:smart-iiot    作者:quanpower    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
项目:SweetHeart    作者:haojunyu    | 项目源码 | 文件源码
def setUp(self):
    self.app = create_app('testing')
    self.app_context = self.app.app_context()
    self.app_context.push()
    db.create_all()
    self.client = self.app.test_client(use_cookies=True)

  # ??????
项目:SweetHeart    作者:haojunyu    | 项目源码 | 文件源码
def setUp(self):
    self.app = create_app()
    self.app_context = self.app.app_context()
    self.app_context.push()
    db.create_all()

  # ??????
项目:SweetHeart    作者:haojunyu    | 项目源码 | 文件源码
def setUp(self):
    self.app = create_app('testing')
    self.app_context = self.app.app_context()
    self.app_context.push()
    db.create_all()

  # ??????
项目:interact    作者:data-8    | 项目源码 | 文件源码
def app():
    """Creates an app with test settings"""
    app = create_app()
    return app
项目:mini    作者:JJWSSS    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('comment')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.init_app(self.app)
        db.create_all()

        table_structs = self.app.config.get('COMMENT_TABLE_STRUCTS')
        table_structs = copy.deepcopy(table_structs)
        table_structs.pop('__tablename__')
        self.proxy = CommentProxy([key for key, value in table_structs.items()])
项目:mini    作者:JJWSSS    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('comment')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.init_app(self.app)
        db.create_all()

        table_structs = self.app.config.get('COMMENT_TABLE_STRUCTS')
        table_structs = copy.deepcopy(table_structs)
        table_structs.pop('__tablename__')
        self.proxy = CommentProxy([key for key, value in table_structs.items()])
项目:mini    作者:JJWSSS    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        Role.insert_roles()
        self.client = self.app.test_client()
项目:maps4all-signup    作者:hack4impact    | 项目源码 | 文件源码
def send_email(recipient, subject, template, **kwargs):
    app = create_app(os.getenv('FLASK_CONFIG') or 'default')
    with app.app_context():
        msg = Message(
            app.config['EMAIL_SUBJECT_PREFIX'] + ' ' + subject,
            sender=app.config['EMAIL_SENDER'],
            recipients=[recipient])
        msg.body = render_template(template + '.txt', **kwargs)
        msg.html = render_template(template + '.html', **kwargs)
        mail.send(msg)
项目:maps4all-signup    作者:hack4impact    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
项目:maps4all-signup    作者:hack4impact    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
项目:database_project    作者:HughWen    | 项目源码 | 文件源码
def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()