in bookstore/books/main.py [0:0]
def put_book(event):
try:
req = json.loads(event['body'])
book = Book(
title=req['title'],
author=req['author'],
publisher=req['publisher'],
year=int(req['year'])
)
logger.debug(f"Inserting: {book}")
session.add(book)
session.commit()
return {
"statusCode": 200
}
except Exception as e:
logger.debug(e)
return {
"statusCode": 500,
"error": f"Error: {e}"
}