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)
def add_recipe(): """ Add a recipe """ validate_request() recipe_obj = rp.Recipe(db_connection) row = recipe_obj.add_recipe(request.json) return jsonify(row)
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)
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)
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)
import model.recipe as re x = 5 g = [1, 2, 3, 4, 5] f = re.Recipe() f.name = 5 print(f)