예제 #1
0
def create_app(test_config=None):
    """Construct the core application."""
    # Create the Flask app object.
    app = Flask(__name__)

    # Configure the app from configuration-file settings.
    app.config.from_object('config.Config')
    data_path = os.path.join('CS235Flix', 'adapters', 'data')

    if test_config is not None:
        # Load test configuration, and override any configuration settings.
        app.config.from_mapping(test_config)
        data_path = app.config['TEST_DATA_PATH']

    # Create the MemoryRepository implementation for a memory-based repository.
    repo.repo_instance = MemoryRepository()
    populate(data_path, repo.repo_instance)

    # Build the application - these steps require an application context.
    with app.app_context():
        # Register blueprints.
        from .authentication import authentication
        app.register_blueprint(authentication.authentication_blueprint)

        from .home import home
        app.register_blueprint(home.home_blueprint)

        from .movies import movies
        app.register_blueprint(movies.movies_blueprint)

        from .utilities import utilities
        app.register_blueprint(utilities.utilities_blueprint)

    return app
예제 #2
0
def create_app(test_config = None):

	app = Flask(__name__)

	app.config.from_object('config.Config') # config is the module name, Config is the class name whose static variables and their values are to be Flask's configuration variables and values
	data_path = os.path.join('CS235Flix', 'adapters', 'data')

	if test_config is not None:
		app.config.from_mapping(test_config) # override any configuration variables with these (test_config should be a dictionary)
		data_path = app.config['TEST_DATA_PATH']


	repo.repo_instance = MemoryRepository()
	populate(data_path, repo.repo_instance)

	with app.app_context():
		from .home_blueprint import home
		app.register_blueprint(home.home_blueprint)

		from .movies_blueprint import movies
		app.register_blueprint(movies.movies_blueprint)

		from .authentication_blueprint import authentication
		app.register_blueprint(authentication.authentication_blueprint)

	return app
예제 #3
0
def in_memory_repo():
    repo = MemoryRepository()
    memory_repository.populate(TEST_DATA_PATH_MEMORY, repo)
    return repo
def blank_memory_repository():
    memory_repository = MemoryRepository()
    return memory_repository
def memory_repository_with_data():
    csv_path = r"C:\Users\Nathan Longhurst\OneDrive - The University of Auckland\b Comp235\Assignment 2\GitHub\Assignment2Comp235\CS235Flix\adapters\data"
    memory_repository = MemoryRepository()
    populate(csv_path, memory_repository)
    return memory_repository
예제 #6
0
def in_memory_repo():
    repo = MemoryRepository()
    populate(TEST_DATA_PATH, repo)
    return repo