Ejemplo n.º 1
0
def recipe(id):
    """ Display recipe by id
    Args:
        id (int): id of recipe to display
    """
    recipe_obj = rp.Recipe(db_connection)
    fields = request.args.get('fields', '*')
    row = recipe_obj.get_recipe_by_id(id, fields)

    return jsonify(row)
Ejemplo n.º 2
0
def add_recipe():
    """ Add a recipe
    """

    validate_request()

    recipe_obj = rp.Recipe(db_connection)
    row = recipe_obj.add_recipe(request.json)

    return jsonify(row)
Ejemplo n.º 3
0
def rating_recipe(id):
    """ Rate recipe by id
    Args:
        id (int): id of recipe to rate
    """
    validate_rating()

    recipe_obj = rp.Recipe(db_connection)
    row = recipe_obj.rate_recipe(id, request.json)

    return jsonify(row)
Ejemplo n.º 4
0
def recipes(cuisine):
    """ Display recipes by cuisine
    Args:
        cuisine (string): cuisine
    """
    recipe_obj = rp.Recipe(db_connection)
    offset = request.args.get('offset', 0)
    limit = request.args.get('limit', 10)
    fields = request.args.get('fields', 'id,slug,title,recipe_cuisine,recipe_diet_type_id,gousto_reference,created_at,updated_at')
    results = recipe_obj.get_recipes_by_cuisine(cuisine, int(offset), int(limit), fields)

    return jsonify(results)
Ejemplo n.º 5
0
def update_recipe(id):
    """ Update recipe
    Args:
        id (int): id of recipe to update
    """

    validate_request()

    recipe_obj = rp.Recipe(db_connection)
    row = recipe_obj.update_recipe(id, request.json)

    return jsonify(row)
Ejemplo n.º 6
0
import model.recipe as re

x = 5
g = [1, 2, 3, 4, 5]
f = re.Recipe()
f.name = 5
print(f)