Example #1
0
def create_app(_name_=None, root=root, config='DevelopmentConfig', **configs):
	"""
	App factory
	:param config: name of Config class from config.py
	"""

	# Create and set app config
	app = Flask(_name_ or __name__)
	app.config.from_object('%s.config.%s' % (root, config))
	app.config.update(**configs)

	# initialize Flask-Login with app
	login_manager.init_app(app)

	# initialize hash mechanism
	hashing.init_app(app)

	# setup blueprints
	def reload_blueprints():
		"""Loads all LIVE blueprints"""
		mod = lambda view: importlib.import_module('%s.%s.views' % (root, view))
		return [getattr(mod(view), view) for view in app.config['LIVE']]

	# Setup blueprints
	def register_blueprints(*blueprints):
		"""Registers all passed-in blueprints"""
		blueprints = list(blueprints) + reload_blueprints()
		for blueprint in blueprints:
			app.register_blueprint(blueprint)

	app.register_blueprints = register_blueprints
	app.register_blueprints()

	return app
Example #2
0
def create_app(config="DevelopmentConfig", root=_root, **configs):
    """
	App factory
	:param config: name of Config class from config.py
	"""

    # Create and set app config
    app = Flask(__name__)
    app.config.from_object("%s.config.%s" % (root, config))
    app.config.update(**configs)

    # initialize MongoEngine with app
    db.init_app(app)

    # initialize hashing mechanism
    hashing.init_app(app)

    # Setup blueprints
    def register_blueprints():
        for view in app.config["LIVE"]:
            mod = importlib.import_module("%s.%s.views" % (_root, view))
            app.register_blueprint(getattr(mod, view))

    app.register_blueprints = register_blueprints
    app.register_blueprints()

    return app
Example #3
0
def build_app(blueprints):
    app = Flask(APP_NAME)
    blueprints = build_blueprints()
    for bp in blueprints:
        app.register_blueprints(bp)
    return app