JaeSwift commited on
Commit
ff8147f
·
verified ·
1 Parent(s): b8ba622

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -28,19 +28,27 @@ h3 {
28
  }
29
  """
30
 
31
- # New Horoscope API URL (Aztro)
32
  AZTRO_API_URL = "https://aztro.sameerkumar.website"
33
 
34
- # Horoscope Function with the Aztro API
35
  def get_horoscope(sign):
36
  try:
37
- # Send a POST request with the sign as a parameter
38
- response = requests.post(f"{AZTRO_API_URL}/?sign={sign}&day=today")
 
 
 
 
 
 
39
  response.raise_for_status()
 
40
  data = response.json()
41
- # Return the horoscope description
42
  return f"<div class='card'>{data.get('description', 'No horoscope available for today.')}</div>"
43
- except requests.exceptions.RequestException:
 
44
  return "<div class='card'>Error retrieving horoscope. Please try again later.</div>"
45
 
46
  # Gradio Interface
 
28
  }
29
  """
30
 
31
+ # Aztro API URL
32
  AZTRO_API_URL = "https://aztro.sameerkumar.website"
33
 
34
+ # Horoscope Function with correct API usage
35
  def get_horoscope(sign):
36
  try:
37
+ # Send a POST request with the sign and day as part of the URL query parameters
38
+ response = requests.post(f"{AZTRO_API_URL}?sign={sign}&day=today")
39
+
40
+ # Debugging statements to inspect response
41
+ print(f"Status Code: {response.status_code}") # Log status code
42
+ print(f"Response Text: {response.text}") # Log response text
43
+
44
+ # Raise an error for non-200 status codes
45
  response.raise_for_status()
46
+
47
  data = response.json()
48
+ # Return the horoscope description if available
49
  return f"<div class='card'>{data.get('description', 'No horoscope available for today.')}</div>"
50
+ except requests.exceptions.RequestException as e:
51
+ print(f"Request Exception: {e}") # Log any exceptions
52
  return "<div class='card'>Error retrieving horoscope. Please try again later.</div>"
53
 
54
  # Gradio Interface