Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -19,46 +19,46 @@ def destiny_still_arrives(name:str, age_or_dob:str)-> str: #it's import to speci
|
|
19 |
age_or_dob: A string representing a person's age or date of birth
|
20 |
"""
|
21 |
def get_birthstone(name: str, age_or_dob: str):
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
return get_birthstone
|
64 |
|
|
|
19 |
age_or_dob: A string representing a person's age or date of birth
|
20 |
"""
|
21 |
def get_birthstone(name: str, age_or_dob: str):
|
22 |
+
birthstones = {
|
23 |
+
"January": "Garnet",
|
24 |
+
"February": "Amethyst",
|
25 |
+
"March": "Aquamarine",
|
26 |
+
"April": "Diamond",
|
27 |
+
"May": "Emerald",
|
28 |
+
"June": "Pearl",
|
29 |
+
"July": "Ruby",
|
30 |
+
"August": "Peridot",
|
31 |
+
"September": "Sapphire",
|
32 |
+
"October": "Opal",
|
33 |
+
"November": "Topaz",
|
34 |
+
"December": "Turquoise"
|
35 |
+
}
|
36 |
+
|
37 |
+
month = datetime.strptime(age_or_dob, "%Y-%m-%d").strftime("%B")
|
38 |
+
birthstone = birthstones.get(month, "Unknown")
|
39 |
+
|
40 |
+
image_urls = {
|
41 |
+
"Garnet": "https://upload.wikimedia.org/wikipedia/commons/1/12/Garnet_rough.jpg",
|
42 |
+
"Amethyst": "https://upload.wikimedia.org/wikipedia/commons/8/8b/Amethyst.jpg",
|
43 |
+
"Aquamarine": "https://upload.wikimedia.org/wikipedia/commons/d/d5/Aquamarine_Brazil.jpg",
|
44 |
+
"Diamond": "https://upload.wikimedia.org/wikipedia/commons/a/a7/Loose_diamond.png",
|
45 |
+
"Emerald": "https://upload.wikimedia.org/wikipedia/commons/4/4f/Emerald.jpg",
|
46 |
+
"Pearl": "https://upload.wikimedia.org/wikipedia/commons/1/17/Pearl_macro.jpg",
|
47 |
+
"Ruby": "https://upload.wikimedia.org/wikipedia/commons/0/0d/Ruby.jpg",
|
48 |
+
"Peridot": "https://upload.wikimedia.org/wikipedia/commons/8/8a/Peridot.jpg",
|
49 |
+
"Sapphire": "https://upload.wikimedia.org/wikipedia/commons/3/35/Sapphire.jpg",
|
50 |
+
"Opal": "https://upload.wikimedia.org/wikipedia/commons/2/2f/Opal_macro.jpg",
|
51 |
+
"Topaz": "https://upload.wikimedia.org/wikipedia/commons/5/56/Topaz.jpg",
|
52 |
+
"Turquoise": "https://upload.wikimedia.org/wikipedia/commons/d/d6/Turquoise.jpg"
|
53 |
+
}
|
54 |
+
|
55 |
+
if birthstone in image_urls:
|
56 |
+
response = requests.get(image_urls[birthstone])
|
57 |
+
img = Image.open(BytesIO(response.content))
|
58 |
+
img.show()
|
59 |
+
return f"Hello {name}, your birthstone is {birthstone}!"
|
60 |
+
else:
|
61 |
+
return f"Hello {name}, we could not determine your birthstone."
|
62 |
|
63 |
return get_birthstone
|
64 |
|