TrainingByPackt/Python-API-Development-Fundamentals

Inquiry

brightmaraba opened this issue · 0 comments

code
On Chapter 2 Activity 4: Implementing The Delete Recipe Function your solution calls for creating a new Routing {Which should be taken care of by the Resources Library}. I do not understand why you couldn't implement a new method delete under the class RecipeResource? As below? It works perfectly as tested in Postman. Thanks and best regards.

def delete(self, recipe_id):

    recipe = next((recipe for recipe in recipe_list if recipe.id == recipe_id), None)

    if recipe is None:
        return {'message': 'recipe not found'}, HTTPStatus.NOT_FOUND

    recipe_list.remove(recipe)
    
    return {}, HTTPStatus.NO_CONTENT