Ejemplo n.º 1
0
    def post(self):
        data = request.get_json()

        recipe = Recipe(name=data['name'],
        description = data['description'],
        num_of_servings = data['num_of_servings'],
        cook_time = data['cook_time'],
        directions = data['directions'])

        recipe_list.append(recipe)

        return recipe.data, HTTPStatus.CREATED
Ejemplo n.º 2
0
    def post(self):
        # get recipe data details from request call (request.get_json())
        data = request.get_json()

        # define data required for post request
        recipe = Recipe(name=data['name'],
                        description=data['description'],
                        num_of_servings=data['num_of_servings'],
                        cook_time=data['cook_time'],
                        directions=data['directions'])

        # add data to recipe list
        recipe_list.append(recipe)

        # return created recipe data to user.
        return recipe.data, HTTPStatus.CREATED