Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,17 +54,18 @@ def get_horoscope(sign: str, date: str = None, language: str = "EN") -> str:
|
|
54 |
language: Language code ('EN' or 'HI')
|
55 |
"""
|
56 |
try:
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
if date:
|
59 |
date_obj = parse_date(date)
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
formatted_date = date_obj.strftime("%d-%m-%Y")
|
64 |
|
65 |
-
# ... (rest of the function is the same)
|
66 |
url = "https://api.exaweb.in:3004/api/rashi"
|
67 |
-
response = requests.get(url, params=
|
68 |
response.raise_for_status()
|
69 |
data = response.json()
|
70 |
|
@@ -72,7 +73,8 @@ def get_horoscope(sign: str, date: str = None, language: str = "EN") -> str:
|
|
72 |
for item in data.get("data", []):
|
73 |
if item.get("sign", "").upper() == sign_upper:
|
74 |
prediction = item.get("prediction", "No prediction found.")
|
75 |
-
|
|
|
76 |
|
77 |
return f"No horoscope found for sign: {sign}"
|
78 |
|
|
|
54 |
language: Language code ('EN' or 'HI')
|
55 |
"""
|
56 |
try:
|
57 |
+
params = {
|
58 |
+
"rashi": sign,
|
59 |
+
"language": language
|
60 |
+
}
|
61 |
+
|
62 |
if date:
|
63 |
date_obj = parse_date(date)
|
64 |
+
formatted_date = date_obj.strftime("%d-%m-%Y")
|
65 |
+
params["day"] = formatted_date # Only include if date is provided
|
|
|
|
|
66 |
|
|
|
67 |
url = "https://api.exaweb.in:3004/api/rashi"
|
68 |
+
response = requests.get(url, params=params)
|
69 |
response.raise_for_status()
|
70 |
data = response.json()
|
71 |
|
|
|
73 |
for item in data.get("data", []):
|
74 |
if item.get("sign", "").upper() == sign_upper:
|
75 |
prediction = item.get("prediction", "No prediction found.")
|
76 |
+
used_date = params.get("day", "today")
|
77 |
+
return f"Horoscope for {sign.capitalize()} on {used_date}:\n{prediction}"
|
78 |
|
79 |
return f"No horoscope found for sign: {sign}"
|
80 |
|