|
|
@ -66,25 +66,20 @@ def all_books():
|
|
|
|
return jsonify(response_object)
|
|
|
|
return jsonify(response_object)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/books/<book_id>', methods=['PUT'])
|
|
|
|
@app.route('/books/<book_id>', methods=['PUT', 'DELETE'])
|
|
|
|
def single_book(book_id):
|
|
|
|
def single_book(book_id):
|
|
|
|
response_object = {'status': 'success'}
|
|
|
|
response_object = {'status': 'success'}
|
|
|
|
if request.method == 'PUT':
|
|
|
|
if request.method == 'PUT':
|
|
|
|
post_data = request.get_json()
|
|
|
|
post_data = request.get_json()
|
|
|
|
# print(post_data)
|
|
|
|
|
|
|
|
#remove_book(book_id)
|
|
|
|
|
|
|
|
# BOOKS.append({
|
|
|
|
|
|
|
|
# 'id': uuid.uuid4().hex,
|
|
|
|
|
|
|
|
# 'title': post_data.get('title'),
|
|
|
|
|
|
|
|
# 'author': post_data.get('author'),
|
|
|
|
|
|
|
|
# 'read': post_data.get('read')
|
|
|
|
|
|
|
|
# })
|
|
|
|
|
|
|
|
for item in BOOKS:
|
|
|
|
for item in BOOKS:
|
|
|
|
print(item['id'])
|
|
|
|
print(item['id'])
|
|
|
|
if item['id'] == post_data['id']:
|
|
|
|
if item['id'] == post_data['id']:
|
|
|
|
item.update(**post_data)
|
|
|
|
item.update(**post_data)
|
|
|
|
break
|
|
|
|
break
|
|
|
|
response_object['message'] = 'Book updated!'
|
|
|
|
response_object['message'] = 'Book updated!'
|
|
|
|
|
|
|
|
if request.method == 'DELETE':
|
|
|
|
|
|
|
|
remove_book(book_id)
|
|
|
|
|
|
|
|
response_object['message'] = 'Book removed!'
|
|
|
|
return jsonify(response_object)
|
|
|
|
return jsonify(response_object)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|