コード例 #1
0
def book_details(book_id):
    book = books.get(book_id - 1)
    form = LibraryForm(data=book)

    if request.method == "POST":
        if form.validate_on_submit():
            books.update(book_id - 1, form.data)
        return redirect(url_for("library_list"))
    return render_template("book.html", form=form, book_id=book_id)
コード例 #2
0
def library_list():
    form = LibraryForm()
    error = ""
    if request.method == "POST":
        if form.validate_on_submit():
            books.create(form.data)
            books.save_all()
        return redirect(url_for("library_list"))

    return render_template("library.html", form=form,  books=books.all(),error=error)