def _get_step(recipe_id): if request.method == 'GET': try: steps = services.get_steps(recipe_id=recipe_id) except NoResultFound: abort(404) return jsonify({'steps': steps}) elif request.method == 'PUT': name = request.form['name'] description = request.form['description'] style = request.form['style'] type = request.form['type'] id = request.form['id'] result = services.edit_recipe(recipe_id=recipe_id, recipe_name=name, description=description, style=style, type=type) resp = jsonify({'recipe': result.data}) resp.status_code = 200 resp.headers['Location'] = '/cah/api/v1.0/recipes/{0}'.format(result.id) resp.autocorrect_location_header = False # Get the parsed contents of the form data json = request.json print(json) # Render template return resp elif request.method == 'PUT': services.delete_recipe(recipe_id)
def _get_client_recipe(client_id, recipe_id): if request.method == 'GET': try: recipe = services.get_client_recipe(client_id=client_id, recipe_id=recipe_id) except NoResultFound: abort(404) return jsonify({'recipe': recipe}) elif request.method == 'PUT': recipe_name = request.form['recipe_name'] description = request.form['description'] style = request.form['style'] type = request.form['type'] result = services.edit_recipe(recipe_id=recipe_id, recipe_name=recipe_name, description=description, style=style, type=type) resp = jsonify({'recipe': result.data}) resp.status_code = 200 resp.headers['Location'] = '/cah/api/v1.0/recipes/{0}'.format(result.id) resp.autocorrect_location_header = False return resp