File size: 1,405 Bytes
bce4d63
7bda51e
bce4d63
7bda51e
 
 
 
bce4d63
 
7bda51e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bce4d63
 
7bda51e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bce4d63
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
import gradio as gr
import requests

PLACEHOLDER = """
<center>
<p>Daily Horoscope by Enemy AI</p>
</center>
"""

CSS = """
.card {
    border: 1px solid black;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.3);
    margin: 10px;
}
h3 {
    text-align: center;
}
.button-container {
    text-align: center;
    margin-top: 20px;
}
.result-container {
    margin-top: 20px;
}
"""

ASTROSEEK_API_URL = "https://api.astroseek.com/horoscope/daily"

# Horoscope Function
def get_horoscope(sign):
    response = requests.get(f"{ASTROSEEK_API_URL}/{sign}")
    if response.status_code == 200:
        data = response.json()
        return data.get("horoscope", "No horoscope available for today.")
    else:
        return "Error retrieving horoscope. Please try again later."

with gr.Blocks(theme="soft", css=CSS) as demo:
    gr.Markdown(PLACEHOLDER)
    gr.Markdown("### Get your daily horoscope.")
    horoscope_output = gr.HTML()
    sign_dropdown = gr.Dropdown(label="Select Your Zodiac Sign", choices=[
        "Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"
    ])
    btn_get_horoscope = gr.Button("Get Horoscope")
    
    btn_get_horoscope.click(fn=get_horoscope, inputs=sign_dropdown, outputs=horoscope_output)

if __name__ == "__main__":
    demo.launch()