Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 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 |
|