nebi commited on
Commit
1cded8d
·
verified ·
1 Parent(s): 21facf8

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -3
src/streamlit_app.py CHANGED
@@ -26,12 +26,19 @@ def fetch_cat_image():
26
 
27
  """Fetches a random cat image from the CATAAS API."""
28
 
29
- response = requests.get('https://cataas.com/cat')
30
  print(f"STATUS_CODE:{response.status_code}")
31
  if response.status_code == 200:
32
- print(f"RESPONSE_RAW:{response.raw}")
 
 
 
 
 
 
 
33
 
34
- return Image.open(response.raw)
35
 
36
  else:
37
 
 
26
 
27
  """Fetches a random cat image from the CATAAS API."""
28
 
29
+ response = requests.get('https://cataas.com/cat?json=true')
30
  print(f"STATUS_CODE:{response.status_code}")
31
  if response.status_code == 200:
32
+ data = response.json()
33
+
34
+ url = data['url']
35
+
36
+ response_image = requests.get(url)
37
+
38
+ if response_image.status_code == 200:
39
+ print(f"SECOND STATUS_CODE:{response_image.status_code}")
40
 
41
+ return Image.open(response_image.raw)
42
 
43
  else:
44