File size: 2,148 Bytes
d61af77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import requests

def check_mangal_dosh(name, dob, tob, lat, lon, tz, api_key):
    url = f"https://api.vedicastroapi.com/v3-json/dosha/mangal-dosh?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 data.get("response"):
            factors = data["response"].get("factors", {})
            dosha_present = data["response"].get("is_dosha_present", False)
            bot_response = data["response"].get("bot_response", "No information available")
            score = data["response"].get("score", "N/A")
            
            readable_response = f"""
            **Mangal Dosh Analysis for {name}:**
            
            **Dosha Presence:** {'Yes' if dosha_present else 'No'}
            **Score:** {score}%
            
            **Detailed Analysis:**
            - **Moon Influence:** {factors.get('moon', 'Not mentioned')}
            - **Saturn Influence:** {factors.get('saturn', 'Not mentioned')}
            - **Rahu Influence:** {factors.get('rahu', 'Not mentioned')}
            
            **Astrological Suggestion:** {bot_response}
            
            """
            return readable_response
        else:
            return "Invalid response from API. Please check input values."
    else:
        return f"Error fetching data: {response.status_code}"

with gr.Blocks() as demo:
    gr.Markdown("# Mangal Dosh Checker 🪐")
    gr.Markdown("Enter your details to check for Mangal Dosh:")
    
    name = gr.Textbox(label="Name")
    dob = gr.Textbox(label="Date of Birth (DD/MM/YYYY)")
    tob = gr.Textbox(label="Time of Birth (HH:MM)")
    lat = gr.Number(label="Latitude")
    lon = gr.Number(label="Longitude")
    tz = gr.Number(label="Time Zone (e.g., 5.5)")
    api_key = gr.Textbox(label="API Key", type="password")
    
    submit_btn = gr.Button("Check Mangal Dosh")
    result = gr.Markdown()
    
    submit_btn.click(check_mangal_dosh, inputs=[name, dob, tob, lat, lon, tz, api_key], outputs=result)

demo.launch()