Ejemplo n.º 1
0
def update_food(_id=""):
    data = request.data
    if request.form:
        data = request.form.keys()[0]
    if not _id:
        _id = data['id']
    if not _id:
        raise Exception("failed to get the id. must supply id as path or in body")
    
    food = get_food_from_es(_id)
    food.update(json.loads(data))
    food = es.index(index="foods", doc_type="food", body=food, id=_id)
    return jsonify(**food), 200, None
Ejemplo n.º 2
0
def get_food():
    foods = get_food_from_es()
    return jsonify(**{"data":foods}), 200, None