Exemple #1
0
    def post(self):
        recipeUrl = self.request.get('recipe_url')

        logging.info("Url Recived:  " + recipeUrl)


        ################################
        ##        Fetch Recipe        ##
        ################################

        recipeObj = Recipe(recipeUrl)

        measurementParserObj = MeasurementParser()
        structuredIngredients = measurementParserObj.Parse(recipeObj.ScrapeIngredients())
        recipeObj.setStructuredIngredients(structuredIngredients)

        structuredDirections = recipeObj.InitDirections()

        structuredIngredientsJsonString = Jsonify.ListToJsonString(structuredIngredients)
        structuredDirectionsJsonString = Jsonify.ListToJsonString(structuredDirections)

        template_values = {
            'RecipeUrl':    recipeUrl,
            'title':        recipeObj.getTitle(),
            'ingredients':  structuredIngredientsJsonString,
            'directions':   structuredDirectionsJsonString,
            'nutrition':    recipeObj.getNutrition()
        }

        template = JINJA_ENVIRONMENT.get_template('RecipeEnginePage.html')
        self.response.write(template.render(template_values))