Matty-Sam commited on
Commit
54f926f
·
verified ·
1 Parent(s): 35addf2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -45,7 +45,7 @@ def search_for_books(author: str) -> list[dict[str,str]]:
45
  """
46
 
47
  max_pages = 5
48
- counter = 0
49
  try:
50
  params = {"search": author}
51
  base_url = 'https://gutendex.com/books'
@@ -54,7 +54,7 @@ def search_for_books(author: str) -> list[dict[str,str]]:
54
  json_data = response.json()
55
 
56
  results = []
57
- while json_data['next']:
58
  print(counter)
59
 
60
  for book in json_data['results']:
@@ -67,7 +67,7 @@ def search_for_books(author: str) -> list[dict[str,str]]:
67
  results.append(book_info)
68
 
69
  counter+=1
70
- if counter >= max_pages:
71
  break
72
  response = requests.get(json_data['next'])
73
  json_data = response.json()
 
45
  """
46
 
47
  max_pages = 5
48
+ counter = 1
49
  try:
50
  params = {"search": author}
51
  base_url = 'https://gutendex.com/books'
 
54
  json_data = response.json()
55
 
56
  results = []
57
+ while counter < max_pages:
58
  print(counter)
59
 
60
  for book in json_data['results']:
 
67
  results.append(book_info)
68
 
69
  counter+=1
70
+ if json_data['next'] is None:
71
  break
72
  response = requests.get(json_data['next'])
73
  json_data = response.json()