def list_ingredients(request): ingrs = Ingredient.query() response_data = {} for ingr in ingrs: data = {} data['name'] = ingr.name response_data[ingr.key.id()] = data return HttpResponse(json.dumps(response_data, indent=2), content_type="application/json")
def get_ingredient(request): response_data = {} ingrs = [] if 'name' in request.GET: ingr_name = request.GET['name'] ingrs = Ingredient.query(Ingredient.name == ingr_name) for ingr in ingrs: data = {} data['name'] = ingr.name # data['image'] = ingr.image response_data[ingr.key.id()] = data return HttpResponse(json.dumps(response_data, indent=2), content_type="application/json")
def test2(request): ingr1 = Ingredient(name = 'vodka') ingr1.put() ingr2 = Ingredient(name = 'pineapple juice') ingr2.put() ingr3 = Ingredient(name = 'coconut rum') ingr3.put() ingr4 = Ingredient(name = 'gin') ingr4.put() ingr5 = Ingredient(name = 'tequila') ingr5.put() ingr6 = Ingredient(name = 'triple sec') ingr6.put() ingr7 = Ingredient(name = 'fresh lime juice') ingr7.put() ingr8 = Ingredient(name = 'rum') ingr8.put() ingr9 = Ingredient(name = 'pineapple juice') ingr9.put() ingr10 = Ingredient(name = 'coconut milk') ingr10.put() return HttpResponse("Hello, world. You're at the ingrediant index.")