Beispiel #1
0
def show(id):
    found_snack = Snack.find_snack(snack_list, id)
    if found_snack is None:
        return render_template('404.html')

    if request.method == b"PATCH":
        found_snack.name = request.form["name"]
        found_snack.kind = request.form["kind"]
        return redirect(url_for("index"))
    return render_template("show.html", snack=found_snack)
Beispiel #2
0
def edit(id):
    found_snack = Snack.find_snack(snack_list, id)
    if found_snack is None:
        return render_template('404.html')
    return render_template("edit.html", snack=found_snack)
Beispiel #3
0
def destroy(id):
    found_snack = Snack.find_snack(snack_list, id)
    snack_list.remove(found_snack)
    return jsonify({"message": "deleted"}, 200)