def create_version(): """Create a version""" controller = VersionController return controller.create(MySQLFactory.get())
def get_games(): """Get the games""" controller = GameController return controller.get_list(MySQLFactory.get())
def get_version_by_id(entity_id): """Returns the version according to its id""" controller = VersionController return controller.get_by_id(MySQLFactory.get(), entity_id)
def get_story_by_id(entity_id): """Returns the story according to its id""" controller = StoryController return controller.get_by_id(MySQLFactory.get(), entity_id)
def authenticate_user(): """Returns the token of the given user""" controller = UserController return controller.authenticate(MySQLFactory.get())
def get_copy_by_id(entity_id): """Returns the copy according to its id""" controller = CopyController return controller.get_by_id(MySQLFactory.get(), entity_id)
def delete_copy(entity_id): """Delete the copy according to its id""" controller = CopyController return controller.delete(MySQLFactory.get(), entity_id)
def create_platform(): """Create a platform""" controller = PlatformController return controller.create(MySQLFactory.get())
def delete_platform(entity_id): """Delete the platform according to its id""" controller = PlatformController return controller.delete(MySQLFactory.get(), entity_id)
def renew_token(current_user): """Renew the API token of the current user""" controller = UserController return controller.renew_token(MySQLFactory.get(), current_user)
def get_platform_by_id(entity_id): """Returns the platform according to its id""" controller = PlatformController return controller.get_by_id(MySQLFactory.get(), entity_id)
def update_user(entity_id): """Updates a user""" controller = UserController return controller.update(MySQLFactory.get(), entity_id)
def create_user(): """Creates a user""" controller = UserController return controller.create(MySQLFactory.get())
def get_user(): """Returns the user according to one filter""" controller = UserController return controller.get_by_filter(MySQLFactory.get(), request.args.get('filter', ''), request.args.get('value', ''))
def delete_version(entity_id): """Delete the version according to its id""" controller = VersionController return controller.delete(MySQLFactory.get(), entity_id)
def get_platforms(): """Get the platforms""" controller = PlatformController return controller.get_list(MySQLFactory.get())
def get_versions(): """Get the versions""" controller = VersionController return controller.get_list(MySQLFactory.get())
def get_game_by_id(entity_id): """Returns the game according to its id""" controller = GameController return controller.get_by_id(MySQLFactory.get(), entity_id)
def create_copy(): """Create a copy""" controller = CopyController return controller.create(MySQLFactory.get())
def create_game(): """Create a game""" controller = GameController return controller.create(MySQLFactory.get())
def get_copies(): """Get the copies""" controller = CopyController return controller.get_list(MySQLFactory.get())
def delete_game(entity_id): """Delete the game according to its id""" controller = GameController return controller.delete(MySQLFactory.get(), entity_id)
def create_story(): """Create a story""" controller = StoryController return controller.create(MySQLFactory.get())
app = Flask(__name__) app.config['JSON_SORT_KEYS'] = False ############## # Load config ############## with open('configuration.json', encoding='UTF-8') as json_file: configurationData = json.load(json_file) ################ # DB connection ################ MySQLFactory.init(configurationData['db_host'], configurationData['db_user'], configurationData['db_password'], configurationData['database']) ################## # User management ################## def token_required(decorated_function): @wraps(decorated_function) def decorator(*args, **kwargs): token = None if 'Authorization' in request.headers: header_value = request.headers['Authorization']