JaeSwift commited on
Commit
1770c82
·
verified ·
1 Parent(s): c00b9ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -28,15 +28,18 @@ h3 {
28
  }
29
  """
30
 
31
- ASTROSEEK_API_URL = "https://api.astroseek.com/horoscope/daily"
 
32
 
33
- # Horoscope Function with improved error handling
34
  def get_horoscope(sign):
35
  try:
36
- response = requests.get(f"{ASTROSEEK_API_URL}/{sign}")
37
- response.raise_for_status() # Raises an error for HTTP codes 400+
 
38
  data = response.json()
39
- return f"<div class='card'>{data.get('horoscope', 'No horoscope available for today.')}</div>"
 
40
  except requests.exceptions.RequestException:
41
  return "<div class='card'>Error retrieving horoscope. Please try again later.</div>"
42
 
@@ -46,11 +49,10 @@ with gr.Blocks(theme="soft", css=CSS) as demo:
46
  gr.Markdown("### Get your daily horoscope.")
47
  horoscope_output = gr.HTML() # Retains the HTML formatting for horoscopes
48
  sign_dropdown = gr.Dropdown(label="Select Your Zodiac Sign", choices=[
49
- "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"
50
  ])
51
  btn_get_horoscope = gr.Button("Get Horoscope")
52
 
53
  btn_get_horoscope.click(fn=get_horoscope, inputs=sign_dropdown, outputs=horoscope_output)
54
 
55
- if __name__ == "__main__":
56
- demo.launch(server_name='0.0.0.0')
 
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
 
 
49
  gr.Markdown("### Get your daily horoscope.")
50
  horoscope_output = gr.HTML() # Retains the HTML formatting for horoscopes
51
  sign_dropdown = gr.Dropdown(label="Select Your Zodiac Sign", choices=[
52
+ "aries", "taurus", "gemini", "cancer", "leo", "virgo", "libra", "scorpio", "sagittarius", "capricorn", "aquarius", "pisces"
53
  ])
54
  btn_get_horoscope = gr.Button("Get Horoscope")
55
 
56
  btn_get_horoscope.click(fn=get_horoscope, inputs=sign_dropdown, outputs=horoscope_output)
57
 
58
+ if _