in optional-kubernetes-engine/bookshelf/crud.py [0:0]
def add():
if request.method == 'POST':
data = request.form.to_dict(flat=True)
# If an image was uploaded, update the data to point to the new image.
image_url = upload_image_file(request.files.get('image'))
if image_url:
data['imageUrl'] = image_url
# If the user is logged in, associate their profile with the new book.
if 'profile' in session:
data['createdBy'] = session['profile']['name']
data['createdById'] = session['profile']['email']
book = get_model().create(data)
q = tasks.get_books_queue()
q.enqueue(tasks.process_book, book['id'])
return redirect(url_for('.view', id=book['id']))
return render_template("form.html", action="Add", book={})