File size: 1,769 Bytes
bce4d63
7bda51e
bce4d63
7bda51e
 
0415e3c
7bda51e
bce4d63
 
7bda51e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bce4d63
 
1770c82
 
7bda51e
1770c82
7bda51e
0415e3c
1770c82
 
 
7bda51e
1770c82
 
0415e3c
 
7bda51e
0415e3c
7bda51e
 
 
0415e3c
7bda51e
1770c82
7bda51e
 
 
 
bce4d63
b8ba622
 
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
56
57
58
59
60
import gradio as gr
import requests

PLACEHOLDER = """
<center>
<p><strong>Daily Horoscope by Enemy AI</strong></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;
}
"""

# New Horoscope API URL (Aztro)
AZTRO_API_URL = "https://aztro.sameerkumar.website"

# Horoscope Function with the Aztro API
def get_horoscope(sign):
    try:
        # Send a POST request with the sign as a parameter
        response = requests.post(f"{AZTRO_API_URL}/?sign={sign}&day=today")
        response.raise_for_status()
        data = response.json()
        # Return the horoscope description
        return f"<div class='card'>{data.get('description', 'No horoscope available for today.')}</div>"
    except requests.exceptions.RequestException:
        return "<div class='card'>Error retrieving horoscope. Please try again later.</div>"

# Gradio Interface
with gr.Blocks(theme="soft", css=CSS) as demo:
    gr.Markdown(PLACEHOLDER)
    gr.Markdown("### Get your daily horoscope.")
    horoscope_output = gr.HTML()  # Retains the HTML formatting for horoscopes
    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(server_name='0.0.0.0')