Setup scoped sesssion creation and teardown for the passed ``app``.

        :param app: a :class:`~flask.Flask` application
335597
def init_app(self, app):
        
        app.scoped_session = self

        @app.teardown_appcontext
        def remove_scoped_session(*args, **kwargs):
            # pylint: disable=missing-docstring,unused-argument,unused-variable
            app.scoped_session.remove()
112153
def init_app(self, app):
        
        if not hasattr(app, 'extensions'):
            app.extensions = {}

        app.extensions['nav'] = self
        app.add_template_global(self.elems, 'nav')

        # register some renderers
        for args in self._renderers:
            register_renderer(app, *args)
56327
def setup(cls, app):  # pragma: no cover
        """"""
        if cls.directive_name is None:
            raise NotImplementedError('directive_name must be set by '
                                      'subclasses of BaseDirective')
        if not app.registry.has_domain('http'):
            setup_httpdomain(app)
        app.add_config_value('{}_harness'.format(cls.directive_name),
                             None, 'env')
        app.add_directive(cls.directive_name, cls)
        app.connect('builder-inited', cls.run_setup)
        app.connect('build-finished', cls.run_teardown)
        app.connect('env-get-outdated', cls.get_outdated_docs)
        app.connect('env-purge-doc', cls.purge_docs)
602045
def after_init_app(self, app: FlaskUnchained):
        
        self.set_json_encoder(app)
        app.before_first_request(self.register_model_resources)
650732
def init_app(self, app):
        

        self.init_blueprint(app)

        if self.flaskcache is not None:
            for func, extension_name in self.CACHED:
                func = getattr(self._extensions[extension_name], func)
                setattr(
                    self._extensions[extension_name],
                    func.__name__,
                    self.flaskcache.memoize()(func)
                )

        return self.blueprint
763122
def create_app(config=None, config_obj=None):
    
    app = Flask(__name__)
    # configure application from external configs
    configure_app(app, config=config, config_obj=config_obj)
    # register different parts of the application
    register_blueprints(app)
    # setup extensions
    bind_extensions(app)
    return app
518275
def _init_app(self, app):
        
        for resource, urls, kwargs in self.resources:
            self._register_view(app, resource, *urls, **kwargs)
785173
def create_app(settings):
    """"""
    app = Flask(__name__)

    # Import settings from file
    for name in dir(settings):
        value = getattr(settings, name)
        if not (name.startswith('_') or isinstance(value, ModuleType)
                or isinstance(value, FunctionType)):
            app.config[name] = value

    # Bootstrapping
    if 'INSTALLED_APPS' in app.config:
        app.installed_apps = app.config.get('INSTALLED_APPS', [])

    # Extensions
    Funnel(app)
    Mobility(app)

    # Register blueprints
    for app_path in app.installed_apps:
        app.register_blueprint(
            getattr(__import__('{0}.views'.format(app_path),
                               fromlist=['blueprint']),
                    'blueprint'))

    # Register error handlers
    register_error_handlers(app)

    @app.context_processor
    def context_processor():
        return dict(config=app.config)

    @app.teardown_request
    def teardown_request(exception=None):
        # Remove the database session if it exists
        if hasattr(app, 'db_session'):
            app.db_session.close()

    return app
883723
def create_app(config_name):
    
    app = Flask(__name__)
    app.config.from_object(CONFIG[config_name])

    BOOTSTRAP.init_app(app)

    # call controllers
    from flask_seguro.controllers.main import main as main_blueprint

    app.register_blueprint(main_blueprint)
    return app
49627
def init_app(self, app):
        
        self.init_extension(app)

        if not hasattr(app, 'extensions'):
            app.extensions = {}
        classname = self.__class__.__name__
        extname = classname.replace('Flask', '').lower()
        app.extensions[extname] = self
725305
def create_app():
    
    
    # Create Flask app load app.config
    app = Flask(__name__)
    app.config.from_object(__name__+'.ConfigClass')

    # Initialize Flask-SQLAlchemy
    db = SQLAlchemy(app)

    # Define the User data-model.
    # NB: Make sure to add flask_user UserMixin !!!
    class User(db.Model, UserMixin):
        __tablename__ = 'users'
        id = db.Column(db.Integer, primary_key=True)
        active = db.Column('is_active', db.Boolean(), nullable=False, server_default='1')

        # User authentication information. The collation='NOCASE' is required
        # to search case insensitively when USER_IFIND_MODE is 'nocase_collation'.
        username = db.Column(db.String(100, collation='NOCASE'), nullable=False, unique=True)
        password = db.Column(db.String(255), nullable=False, server_default='')
        email_confirmed_at = db.Column(db.DateTime())

        # User information
        first_name = db.Column(db.String(100, collation='NOCASE'), nullable=False, server_default='')
        last_name = db.Column(db.String(100, collation='NOCASE'), nullable=False, server_default='')

    # Create all database tables
    db.create_all()

    # Setup Flask-User and specify the User data-model
    user_manager = UserManager(app, db, User)

    # The Home page is accessible to anyone
    @app.route('/')
    def home_page():
        # String-based templates
        return render_template_string("""
            {% extends "flask_user_layout.html" %}
            {% block content %}
                <h2>Home page</h2>
                <p><a href={{ url_for('user.register') }}>Register</a></p>
                <p><a href={{ url_for('user.login') }}>Sign in</a></p>
                <p><a href={{ url_for('home_page') }}>Home page</a> (accessible to anyone)</p>
                <p><a href={{ url_for('member_page') }}>Member page</a> (login required)</p>
                <p><a href={{ url_for('user.logout') }}>Sign out</a></p>
            {% endblock %}
            """)

    # The Members page is only accessible to authenticated users via the @login_required decorator
    @app.route('/members')
    @login_required    # User must be authenticated
    def member_page():
        # String-based templates
        return render_template_string("""
            {% extends "flask_user_layout.html" %}
            {% block content %}
                <h2>Members page</h2>
                <p><a href={{ url_for('user.register') }}>Register</a></p>
                <p><a href={{ url_for('user.login') }}>Sign in</a></p>
                <p><a href={{ url_for('home_page') }}>Home page</a> (accessible to anyone)</p>
                <p><a href={{ url_for('member_page') }}>Member page</a> (login required)</p>
                <p><a href={{ url_for('user.logout') }}>Sign out</a></p>
            {% endblock %}
            """)

    return app
218948
def setup(self, app):
        
        super().setup(app)

        self.handlers = OrderedDict()

        # Connect admin templates
        app.ps.jinja2.cfg.template_folders.append(op.join(PLUGIN_ROOT, 'templates'))

        @app.ps.jinja2.filter
        def admtest(value, a, b=None):
            return a if value else b

        @app.ps.jinja2.filter
        def admeq(a, b, result=True):
            return result if a == b else not result

        @app.ps.jinja2.register
        def admurl(request, prefix):
            qs = {k: v for k, v in request.query.items() if not k.startswith(prefix)}
            if not qs:
                qs = {'ap': 0}
            return "%s?%s" % (request.path, urlparse.urlencode(qs))

        if self.cfg.name is None:
            self.cfg.name = "%s admin" % app.name.title()

        # Register a base view
        if not callable(self.cfg.home):

            def admin_home(request):
                yield from self.authorize(request)
                return app.ps.jinja2.render(self.cfg.template_home, active=None)

            self.cfg.home = admin_home

        app.register(self.cfg.prefix)(self.cfg.home)

        if not self.cfg.i18n:
            app.ps.jinja2.env.globals.update({
                '_': lambda s: s,
                'gettext': lambda s: s,
                'ngettext': lambda s, p, n: (n != 1 and (p,) or (s,))[0],
            })

            return

        if 'babel' not in app.ps or not isinstance(app.ps.babel, BPlugin):
            raise PluginException(
                'Plugin `%s` requires for plugin `%s` to be installed to the application.' % (
                    self.name, BPlugin))

        # Connect admin locales
        app.ps.babel.cfg.locales_dirs.append(op.join(PLUGIN_ROOT, 'locales'))
        if not app.ps.babel.locale_selector_func:
            app.ps.babel.locale_selector_func = app.ps.babel.select_locale_by_request
766730
def create_app(self, apps_path, name):
        
        app_path = os.path.join(apps_path, name.lower())

        shutil.copytree(self.app_path, app_path)

        self.update_file(app_path, '__init__.py', {
            'name': name.lower()
        })

        self.update_file(app_path, 'apps.py', {
            'name': name.lower(),
            'verbose_name': name.capitalize()
        })
1247949
def init_app(state):
    
    app = state.app

    app.config.setdefault('SPLIT_ALLOW_MULTIPLE_EXPERIMENTS', False)
    app.config.setdefault('SPLIT_DB_FAILOVER', False)
    app.config.setdefault('SPLIT_IGNORE_IP_ADDRESSES', [])
    app.config.setdefault('SPLIT_ROBOT_REGEX', r"""
        (?i)\b(
            Baidu|
            Gigabot|
            Googlebot|
            libwww-perl|
            lwp-trivial|
            msnbot|
            SiteUptime|
            Slurp|
            WordPress|
            ZIBB|
            ZyBorg
        )\b
    """)

    app.jinja_env.globals.update({
        'ab_test': ab_test,
        'finished': finished
    })

    @app.template_filter()
    def percentage(number):
        number *= 100
        if abs(number) < 10:
            return "%.1f%%" % round(number, 1)
        else:
            return "%d%%" % round(number)
1276256
def configure_app(app, config=None, config_obj=None):
    
    app.config.from_object(config_obj or BaseConfig)
    if config is not None:
        app.config.from_pyfile(config)
784634
def init_app(self, app):
        
        provider = app.config.get("STORAGE_PROVIDER", None)
        key = app.config.get("STORAGE_KEY", None)
        secret = app.config.get("STORAGE_SECRET", None)
        container = app.config.get("STORAGE_CONTAINER", None)
        allowed_extensions = app.config.get("STORAGE_ALLOWED_EXTENSIONS", None)
        serve_files = app.config.get("STORAGE_SERVER", True)
        serve_files_url = app.config.get("STORAGE_SERVER_URL", "files")

        self.config["serve_files"] = serve_files
        self.config["serve_files_url"] = serve_files_url

        if not provider:
            raise ValueError("'STORAGE_PROVIDER' is missing")

        if provider.upper() == "LOCAL":
            if not os.path.isdir(container):
                raise IOError("Local Container (directory) '%s' is not a "
                              "directory or doesn't exist for LOCAL provider" % container)

        self.__init__(provider=provider,
                      key=key,
                      secret=secret,
                      container=container,
                      allowed_extensions=allowed_extensions)

        self._register_file_server(app)
756937
def setup(app) -> Dict[str, Any]:
    
    app.connect("doctree-read", on_doctree_read)
    app.connect("builder-inited", on_builder_inited)
    app.add_css_file("uqbar.css")
    app.add_node(
        nodes.classifier, override=True, html=(visit_classifier, depart_classifier)
    )
    app.add_node(
        nodes.definition, override=True, html=(visit_definition, depart_definition)
    )
    app.add_node(nodes.term, override=True, html=(visit_term, depart_term))
    return {
        "version": uqbar.__version__,
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }