Ejemplo n.º 1
0
def create_app(environment, port):
    flask = Flask(__name__)
    flask.config.from_pyfile('config.py')

    config_loader = ConfigLoader(verify=False)
    info = config_loader.load_application_info("./")
    config = config_loader.load_config("resources/", environment)

    view_util.navigation_bar = navigation_bar
    view_util.app_name = info['name']

    status.blueprint.navigation_bar = navigation_bar
    status.blueprint.info = info
    status.blueprint.environment = environment
    status.blueprint.port = port
    status.blueprint.start_time = Delorean.now()

    mongo = MongoConnect(config)
    state.mongo = mongo

    views.blueprint.mongo = mongo
    views.blueprint.config = config['app']
    api.blueprint.mongo = mongo
    api.blueprint.config = config['app']

    flask.register_blueprint(status.blueprint)
    flask.register_blueprint(views.blueprint)
    flask.register_blueprint(api.blueprint)
    return flask
Ejemplo n.º 2
0
def create_app(port, environment, working_dir, greedy_mode):
    flask = Flask(__name__)
    flask.config.from_pyfile('config.py')

    flask.jinja_env.filters['ceil'] = view_util.ceil

    config_loader = ConfigLoader(verify=False)
    config.info = config_loader.load_application_info("./")
    config.config = config_loader.load_config("resources/",
                                              environment,
                                              fill_with_defaults=True)
    config.rdb = redislite.Redis(working_dir + 'redis.db')
    config.rdb.flushall()
    config.rdb.flushdb()

    start_tasks(config.config, greedy_mode)

    register_status_page(flask, config.rdb, config.info, environment, port)

    flask.register_blueprint(views.blueprint)
    flask.register_blueprint(styleguide.blueprint)

    return flask