def handleRecipeRetrieve(self, recipeID): db = GroceryDB() if not db.recipeExists(recipeID): self.handle404("Recipe does not exist.") else: recipe = db.getRecipe(recipeID) self.handle200JSONResponse(recipe)
def handleUpdateRecipe(self, recipeID): parsedBody = self.getParsedBody() db = GroceryDB() if not db.recipeExists(recipeID): self.handle404("Recipe does not exist.") else: recipe = db.getRecipe(recipeID) label = recipe["label"] instructions = recipe["instructions"] if parsedBody.get("label") != None: label = parsedBody["label"][0].strip() if parsedBody.get("instructions") != None: instructions = parsedBody["instructions"][0].strip() db.updateRecipe(recipeID, label, instructions) self.handle201("Recipe updated.")