Spaces:
Sleeping
Sleeping
burtenshaw
commited on
Commit
·
e28fc42
1
Parent(s):
606a083
deal with missing profile
Browse files
app.py
CHANGED
|
@@ -17,8 +17,14 @@ COURSE_TITLE = os.getenv("COURSE_TITLE", "AI Agents Fundamentals")
|
|
| 17 |
|
| 18 |
def download_profile_picture(profile_url: str):
|
| 19 |
"""Download profile picture from URL."""
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
def generate_certificate(certificate_path: str, name: str, profile_url: str):
|
|
|
|
| 17 |
|
| 18 |
def download_profile_picture(profile_url: str):
|
| 19 |
"""Download profile picture from URL."""
|
| 20 |
+
try:
|
| 21 |
+
response = requests.get(profile_url)
|
| 22 |
+
response.raise_for_status() # Ensure we got a proper response
|
| 23 |
+
return Image.open(BytesIO(response.content))
|
| 24 |
+
except Exception as e:
|
| 25 |
+
print(f"Error downloading profile picture from {profile_url}: {e}")
|
| 26 |
+
# Return a default fallback image (a plain white 100x100 image)
|
| 27 |
+
return Image.new("RGB", (100, 100), color="white")
|
| 28 |
|
| 29 |
|
| 30 |
def generate_certificate(certificate_path: str, name: str, profile_url: str):
|