def book_save(id): nonlocal books_list title = request.form['title'] author = request.form['author'] price = request.form['price'] tags = request.form['tags'] url = request.form['url'] if id == 'new': book = create_book(title=title, author=author, price=price, tags=tags, url=url) books_list = add_book(books_list, book) else: books_list = remove_book_by_id(books_list, id) book = change_book(id=id, title=title, author=author, price=price, tags=tags, url=url) books_list = add_book(books_list, book) return redirect(url_for('book_details', id=book['id']))
def book_remove(book_id): nonlocal container container = remove_book_by_id(container, book_id) return redirect(url_for('index'))
def book_remove(id): nonlocal books_list books_list = remove_book_by_id(books_list, id) return redirect(url_for('index'))