Creates a Flask Application that can be started.
508378
def create(self):
        
        self._app = Flask(__name__)

        path = '/2015-03-31/functions/<function_name>/invocations'
        self._app.add_url_rule(path,
                               endpoint=path,
                               view_func=self._invoke_request_handler,
                               methods=['POST'],
                               provide_automatic_options=False)

        # setup request validation before Flask calls the view_func
        self._app.before_request(LocalLambdaInvokeService.validate_request)

        self._construct_error_handling()
714516
def init_app(self, app):
    

    app.config.setdefault(FEATURE_FLAGS_CONFIG, {})
    app.config.setdefault(RAISE_ERROR_ON_MISSING_FEATURES, False)

    if hasattr(app, "add_template_test"):
      # flask 0.10 and higher has a proper hook
      app.add_template_test(self.check, name=self.JINJA_TEST_NAME)
    else:
      app.jinja_env.tests[self.JINJA_TEST_NAME] = self.check

    if not hasattr(app, 'extensions'):
      app.extensions = {}
    app.extensions[EXTENSION_NAME] = self
391610
def create_cli(create_app=None):
    
    def create_cli_app(info):
        """Application factory for CLI app.

        Internal function for creating the CLI. When invoked via
        ``inveniomanage`` FLASK_APP must be set.
        """
        if create_app is None:
            # Fallback to normal Flask behavior
            info.create_app = None
            app = info.load_app()
        else:
            app = create_app(debug=get_debug_flag())
        return app

    @click.group(cls=FlaskGroup, create_app=create_cli_app)
    def cli(**params):
        """Command Line Interface for Invenio."""
        pass

    return cli
466099
def init():
    """"""
    global app
    if app: return app
    conf.init(), db.init(conf.DbPath, conf.DbStatements)

    bottle.TEMPLATE_PATH.insert(0, conf.TemplatePath)
    app = bottle.default_app()
    bottle.BaseTemplate.defaults.update(get_url=app.get_url)
    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
863783
def create_app(cls, port):
        
        app = FrontEndApp()
        app_server = GeventServer(app, port=port, hostname='0.0.0.0')
        return app_server
52903
def create():
    ''''''
    data = {
        'first_name': click.prompt('First name'),
        'last_name': click.prompt('Last name'),
        'email': click.prompt('Email'),
        'password': click.prompt('Password', hide_input=True),
        'password_confirm': click.prompt('Confirm Password', hide_input=True),
    }
    # Until https://github.com/mattupstate/flask-security/issues/672 is fixed
    with current_app.test_request_context():
        form = RegisterForm(MultiDict(data), meta={'csrf': False})
    if form.validate():
        data['password'] = encrypt_password(data['password'])
        del data['password_confirm']
        data['confirmed_at'] = datetime.utcnow()
        user = datastore.create_user(**data)
        success('User(id={u.id} email={u.email}) created'.format(u=user))
        return user
    errors = '\n'.join('\n'.join(e) for e in form.errors.values())
    exit_with_error('Error creating user', errors)
17995
def run(self):
        
        if not self._app:
            raise RuntimeError("The application must be created before running")

        # Flask can operate as a single threaded server (which is default) and a multi-threaded server which is
        # more for development. When the Lambda container is going to be debugged, then it does not make sense
        # to turn on multi-threading because customers can realistically attach only one container at a time to
        # the debugger. Keeping this single threaded also enables the Lambda Runner to handle Ctrl+C in order to
        # kill the container gracefully (Ctrl+C can be handled only by the main thread)
        multi_threaded = not self.is_debugging

        LOG.debug("Localhost server is starting up. Multi-threading = %s", multi_threaded)

        # This environ signifies we are running a main function for Flask. This is true, since we are using it within
        # our cli and not on a production server.
        os.environ['WERKZEUG_RUN_MAIN'] = 'true'

        self._app.run(threaded=multi_threaded, host=self.host, port=self.port)
764298
function createApplication() {
  var app = connect();
  utils.merge(app, proto);
  app.request = { __proto__: req };
  app.response = { __proto__: res };
  app.init();
  return app;
}
1103340
def initialize(self, app: Flask, app_config):
        
        debug = app_config["debug"]
        port = app_config["http.port"]
        if debug:
            self.started_on_port = port
            app.run(host="0.0.0.0", debug=True, port=port)
        else:
            for port in range(port, port + 50):
                self.http_server = WSGIServer(('0.0.0.0', port), app)
                try:
                    self.http_server.start()
                except OSError:
                    # try next port
                    continue
                self.started_on_port = port
                break
976621
def init_app(self, app):
        
        config_log_level = app.config.get('FLASK_LOG_LEVEL', None)

        # Set up format for default logging
        hostname = platform.node().split('.')[0]
        formatter = (
            '[%(asctime)s] %(levelname)s %(process)d [%(name)s] '
            '%(filename)s:%(lineno)d - '
            '[{hostname}] - %(message)s'
        ).format(hostname=hostname)

        config_log_int = None
        set_level = None

        if config_log_level:
            config_log_int = getattr(logging, config_log_level.upper(), None)
            if not isinstance(config_log_int, int):
                raise ValueError(
                    'Invalid log level: {0}'.format(config_log_level)
                )
            set_level = config_log_int

        # Set to NotSet if we still aren't set yet
        if not set_level:
            set_level = config_log_int = logging.NOTSET
        self.log_level = set_level

        # Setup basic StreamHandler logging with format and level (do
        # setup in case we are main, or change root logger if we aren't.
        logging.basicConfig(format=formatter)
        root_logger = logging.getLogger()
        root_logger.setLevel(set_level)

        # Get everything ready to setup the syslog handlers
        address = None
        if os.path.exists('/dev/log'):
            address = '/dev/log'
        elif os.path.exists('/var/run/syslog'):
            address = '/var/run/syslog'
        else:
            address = ('127.0.0.1', 514)
        # Add syslog handler before adding formatters
        root_logger.addHandler(
            SysLogHandler(address=address, facility=SysLogHandler.LOG_LOCAL0)
        )
        self.set_formatter(formatter)

        return config_log_int
177668
def _init_application(self, application=None):
        """"""
        if application:
            self.application = application
        else:
            self.application = self.make_application()
1266599
def init_app(self, app):
        
        self.enabled = app.config.get("CAPTCHA_ENABLE", True)
        self.digits = app.config.get("CAPTCHA_LENGTH", 4)
        self.max = 10**self.digits
        self.image_generator = ImageCaptcha()
        self.rand = SystemRandom()

        def _generate():
            if not self.enabled:
                return ""
            base64_captcha = self.generate()
            return Markup("<img src='{}'>".format("data:image/png;base64, {}".format(base64_captcha)))

        app.jinja_env.globals['captcha'] = _generate
        
        # Check for sessions that do not persist on the server. Issue a warning because they are most likely open to replay attacks.
        # This addon is built upon flask-session.
        session_type = app.config.get('SESSION_TYPE', None)
        if session_type is None or session_type == "null":
            raise RuntimeWarning("Flask-Sessionstore is not set to use a server persistent storage type. This likely means that captchas are vulnerable to replay attacks.")
        elif session_type == "sqlalchemy":
            # I have to do this as of version 0.3.1 of flask-session if using sqlalchemy as the session type in order to create the initial database.
            # Flask-sessionstore seems to have the same problem. 
            app.session_interface.db.create_all()
1300586
def before_init_app(self, app: FlaskUnchained):
        
        from .templates import (UnchainedJinjaEnvironment,
                                UnchainedJinjaLoader)
        app.jinja_environment = UnchainedJinjaEnvironment
        app.jinja_options = {**app.jinja_options,
                             'loader': UnchainedJinjaLoader(app)}
        app.jinja_env.globals['url_for'] = url_for

        for name in ['string', 'str']:
            app.url_map.converters[name] = StringConverter
191826
def create(self):
        

        self._app = Flask(__name__,
                          static_url_path="",  # Mount static files at root '/'
                          static_folder=self.static_dir  # Serve static files from this directory
                          )

        for api_gateway_route in self.routing_list:
            path = PathConverter.convert_path_to_flask(api_gateway_route.path)
            for route_key in self._generate_route_keys(api_gateway_route.methods,
                                                       path):
                self._dict_of_routes[route_key] = api_gateway_route

            self._app.add_url_rule(path,
                                   endpoint=path,
                                   view_func=self._request_handler,
                                   methods=api_gateway_route.methods,
                                   provide_automatic_options=False)

        self._construct_error_handling()
1360650
def create_app(config_filename, instance_path=None):
    
    app_ = CustomFlask(
        __name__,
        instance_path=instance_path or os.environ.get(
            'VERIPRESS_INSTANCE_PATH') or os.getcwd(),
        instance_relative_config=True
    )
    app_.config.update(dict(STORAGE_TYPE='file',
                            THEME='default',
                            CACHE_TYPE='simple',
                            MODE='view-only',
                            ENTRIES_PER_PAGE=5,
                            FEED_COUNT=10,
                            SHOW_TOC=True,
                            TOC_DEPTH=3,
                            TOC_LOWEST_LEVEL=3,
                            ALLOW_SEARCH_PAGES=True,
                            PAGE_SOURCE_ACCESSIBLE=False))
    app_.config.from_pyfile(config_filename, silent=True)

    theme_folder = os.path.join(app_.instance_path,
                                'themes', app_.config['THEME'])
    # use templates in the selected theme's folder
    app_.template_folder = os.path.join(theme_folder, 'templates')
    # use static files in the selected theme's folder
    app_.theme_static_folder = os.path.join(theme_folder, 'static')
    # global static folder
    app_.static_folder = os.path.join(app_.instance_path, 'static')

    return app_