0
@app.route('/api/<string:isbn>', methods = ['GET'])
def isbn(isbn):
#import api from Goodreads (stats)

   book_data = db.execute("SELECT * FROM books WHERE isbn=:isbn",{'isbn':isbn}).fetchone()
   title = book_data['title']
   author = book_data['author']
   year = book_data['year']
   isbn = isbn
   res = requests.get("https://www.goodreads.com/book/review_counts.json", params={"key": "XDa8UgD46xzhPHGBPqQng", "isbns":isbn }).json()

  reviews_count = float(res['books'][0]['reviews_count'])
  avg_rating = float(res['books'][0]['average_rating'])
  dic = {"title": title, "author":author, "year": year,"isbn":isbn,"reviews_count":reviews_count,"avg_score":avg_rating}
  print(dic)
  return jsonify(dic)

'' my this code is giving me an error like

in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

it is appearing only when the isbn nmbr i specify has less than 10 characters. otherwise i am getting the correct result for 10 character isbn. can anybody tell me why and how it can be solved.

also if this code:

if res.status_code != 404:
    raise Exception("ERROR: NOT FOUND.")

is added it is giving me the error like if res.status_code != 404: AttributeError: 'dict' object has no attribute 'status_code'

You must log in to answer this question.

Browse other questions tagged .