def Match(): # Getting the POST Request Body Data Data = request.data # Converting Text/Plain to JSON Structure JsonData = json.loads(Data) # Extracting product titles and product classes titles = JsonData["products"] engine = r.Knowledge() predictions = [] for title in titles: engine.reset() engine.declare(Fact(title=title)) engine.run() # Run it! prediction = engine.category predictions.append(prediction) response = { "predictions":predictions, } return jsonify(response)