File size: 8,686 Bytes
d61af77
 
 
c6ebf38
 
8916b04
c6ebf38
 
d61af77
 
 
 
c6ebf38
 
d61af77
79f91c5
d61af77
79f91c5
c6ebf38
fa17637
9908d78
fa17637
 
 
 
 
 
 
0804605
 
fa17637
0804605
fa17637
0804605
 
d796ca3
0804605
 
 
 
 
 
 
d796ca3
0804605
fa17637
 
 
9908d78
c6ebf38
 
79f91c5
c6ebf38
d796ca3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d61af77
aac07ec
 
168692a
aac07ec
 
 
 
106417c
aac07ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3993369
 
fbc9d9d
 
3993369
 
 
 
fbc9d9d
3993369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90bbbb1
8916b04
dfd6008
44dc108
 
8916b04
 
47e0838
d61af77
44dc108
c05d2a6
 
47e0838
d61af77
c6ebf38
9908d78
90bbbb1
 
9908d78
8916b04
c6ebf38
79f91c5
 
 
 
 
c6ebf38
8916b04
c6ebf38
4d2567b
 
 
 
9908d78
 
 
 
 
 
 
 
4733d34
fbc9d9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3993369
4733d34
3993369
 
 
 
d6e9bfd
c6ebf38
8916b04
fa17637
c6ebf38
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import gradio as gr
import requests

API_KEY = "d6cf6f2e-301e-5f63-a988-b0a3aefd0896"

# Function to fetch astrology data
def fetch_astrology_data(endpoint, dob, tob, lat, lon, tz):
    url = f"https://api.vedicastroapi.com/v3-json/{endpoint}?dob={dob}&tob={tob}&lat={lat}&lon={lon}&tz={tz}&api_key={API_KEY}&lang=en"
    response = requests.get(url)
    
    if response.status_code == 200:
        data = response.json()
        if data.get("status") == 200 and "response" in data:
            return data["response"]
        else:
            return f"Invalid response from API: {data.get('message', 'No message provided')}"
    else:
        return f"Error fetching data: {response.status_code} - {response.text}"

# Function to check Dosha
def check_dosha(dosha_type, name, dob, tob, lat, lon, tz):
    response = fetch_astrology_data(f"dosha/{dosha_type}", dob, tob, lat, lon, tz)
    if isinstance(response, str):
        return gr.Markdown(response)
    
    readable_response = f"""
    ### {dosha_type.replace('-', ' ').title()} Analysis for {name}
    
    **Dosha Presence:** {'Yes' if response.get('is_dosha_present', False) else 'No'}
    **Score:** {response.get('score', 'N/A')}%
    
    **Details:**
    """
    
    for key, value in response.items():
        readable_response += f"\n- **{key.replace('_', ' ').title()}**: "
        if isinstance(value, dict):
            for sub_key, sub_value in value.items():
                readable_response += f"\n  - {sub_key.replace('_', ' ').title()}: {sub_value}"
        elif isinstance(value, list):
            for item in value:
                readable_response += f"\n  - {item}"
        else:
            readable_response += f"{value}"
    
    return gr.Markdown(readable_response)

# Function to check Dasha
def check_dasha(dasha_type, name, dob, tob, lat, lon, tz):
    response = fetch_astrology_data(f"dashas/{dasha_type}", dob, tob, lat, lon, tz)
    if isinstance(response, str):
        return gr.Markdown(response)
    
    readable_response = f"""
    ### {dasha_type.replace('-', ' ').title()} Analysis for {name}
    
    **Details:**
    """
    
    for key, value in response.items():
        readable_response += f"\n- **{key.replace('_', ' ').title()}**: "
        if isinstance(value, dict):
            for sub_key, sub_value in value.items():
                readable_response += f"\n  - {sub_key.replace('_', ' ').title()}: {sub_value}"
        elif isinstance(value, list):
            for item in value:
                readable_response += f"\n  - {item}"
        else:
            readable_response += f"{value}"
    
    return gr.Markdown(readable_response)

# Function to check Extended Horoscope
def check_extended_horoscope(horoscope_type, name, dob, tob, lat, lon, tz):
    response = fetch_astrology_data(f"extended-horoscope/{horoscope_type}", dob, tob, lat, lon, tz)
    if isinstance(response, str):
        return gr.Markdown(response)

    readable_response = f"""
    ### {horoscope_type.replace('-', ' ').title()} Analysis for {name}
        
    **Details:**
    """
    
    for key, value in response.items():
        readable_response += f"\n- **{key.replace('_', ' ').title()}**: "
        if isinstance(value, dict):
            for sub_key, sub_value in value.items():
                readable_response += f"\n  - {sub_key.replace('_', ' ').title()}: {sub_value}"
        elif isinstance(value, list):
            for item in value:
                readable_response += f"\n  - {item}"
        else:
            readable_response += f"{value}"
    
    return gr.Markdown(readable_response)


# Function to check Horoscope(Kundali)
def check_horoscope(horoscope_kundali_type, name, dob, tob, lat, lon, tz):
    response = fetch_astrology_data(f"horoscope/{horoscope_kundali_type}", dob, tob, lat, lon, tz)
    if isinstance(response, str):
        return gr.Markdown(response)

    readable_response = f"""
    ### {horoscope_kundali_type.replace('-', ' ').title()} Analysis for {name}
        
    **Details:**
    """
    
    for key, value in response.items():
        readable_response += f"\n- **{key.replace('_', ' ').title()}**: "
        if isinstance(value, dict):
            for sub_key, sub_value in value.items():
                readable_response += f"\n  - {sub_key.replace('_', ' ').title()}: {sub_value}"
        elif isinstance(value, list):
            for item in value:
                readable_response += f"\n  - {item}"
        else:
            readable_response += f"{value}"
    
    return gr.Markdown(readable_response)


# Gradio UI with improvements
with gr.Blocks(theme=gr.themes.Soft()) as demo:
    gr.Markdown("# 🪐 Astrology Checker")
    
    with gr.Row():
        name = gr.Textbox(label="Name", placeholder="Enter your name")
        dob = gr.Textbox(label="DOB (DD/MM/YYYY)", placeholder="21/04/2021")
        tob = gr.Textbox(label="Time of Birth (HH:MM)", placeholder="11:40")
    
    with gr.Row():
        lat = gr.Number(label="Latitude", value=23)
        lon = gr.Number(label="Longitude", value=78)
        tz = gr.Number(label="Timezone (e.g., 5.5 for India)", value=5.5)
    
    result = gr.Markdown()
    
    def create_button(label, dosha_type, fn):
        return gr.Button(label, variant="primary").click(fn, inputs=[gr.State(dosha_type), name, dob, tob, lat, lon, tz], outputs=result)
    
    gr.Markdown("## 🌟 Dosha Analysis")
    with gr.Row():
        create_button("Mangal Dosh", "mangal-dosh", check_dosha)
        create_button("Kaalsarp Dosh", "kaalsarp-dosh", check_dosha)
        create_button("Manglik Dosh", "manglik-dosh", check_dosha)
        create_button("Pitra Dosh", "pitra-dosh", check_dosha)
        create_button("Papasamaya", "papasamaya", check_dosha)
    
    gr.Markdown("## 🔮 Dasha Analysis")
    with gr.Row():
        create_button("Mahadasha", "maha-dasha", check_dasha)
        create_button("Mahadasha Predictions", "maha-dasha-predictions", check_dasha)
        create_button("Antardasha", "antar-dasha", check_dasha)
        create_button("Char Dasha Current", "char-dasha-current", check_dasha)
        create_button("Char Dasha Main", "char-dasha-main", check_dasha)
        create_button("Char Dasha Sub", "char-dasha-sub", check_dasha)
        create_button("Current Mahadasha Full", "current-mahadasha-full", check_dasha)
        create_button("Current Mahadasha", "current-mahadasha", check_dasha)
        create_button("Paryantar Dasha", "paryantar-dasha", check_dasha)
        create_button("Specific Dasha", "specific-sub-dasha", check_dasha)
        create_button("Yogini Dasha Main", "yogini-dasha-main", check_dasha)
        create_button("Yogini Dasha Sub", "yogini-dasha-sub", check_dasha)

    gr.Markdown("## 🌙 Extended Horoscope")
    with gr.Row():
        create_button("Find Moon Sign", "find-moon-sign", check_extended_horoscope)
        create_button("Find Sun Sign", "find-sun-sign", check_extended_horoscope)
        create_button("Find Ascendant", "find-ascendant", check_extended_horoscope)
        create_button("Current Sade Sati", "current-sade-sati", check_extended_horoscope)
        create_button("Extended Kundli Details", "extended-kundli-details", check_extended_horoscope)
        create_button("Sade Sati Table", "sade-sati-table", check_extended_horoscope)
        create_button("Friendship", "friendship", check_extended_horoscope)
        create_button("Kp Houses", "kp-houses", check_extended_horoscope)
        create_button("Kp Planets", "kp-planets", check_extended_horoscope)
        create_button("Gem Suggestion", "gem-suggestion", check_extended_horoscope)
        create_button("Numero Table", "numero-table", check_extended_horoscope)
        create_button("Rudraksh Suggestion", "rudraksh-suggestion", check_extended_horoscope)
        create_button("Varshapal Details", "varshapal-details", check_extended_horoscope)
        create_button("Varshapal Month Chart", "varshapal-month-chart", check_extended_horoscope)
        create_button("Varshapal Year Chart", "varshapal-year-chart", check_extended_horoscope)
        create_button("Yoga List", "yoga-list", check_extended_horoscope)


    gr.Markdown("## 💫 Horoscope")
    with gr.Row():
        create_button("Planet Details", "planet-details", check_horoscope)
        create_button("Ascendant Report", "ascendant-report", check_horoscope)
        create_button("Planet Report", "planet-report", check_horoscope)
        create_button("Personal Characteristics", "personal-characteristics", check_horoscope)

    
    gr.Markdown("### 🔍 Enter your details above and click the relevant button to analyze your astrology report!")
    
    demo.launch()