Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
def check_mangal_dosh(name, dob, tob, lat, lon, tz, api_key):
|
5 |
+
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"
|
6 |
+
response = requests.get(url)
|
7 |
+
|
8 |
+
if response.status_code == 200:
|
9 |
+
data = response.json()
|
10 |
+
if data.get("status") == 200 and data.get("response"):
|
11 |
+
factors = data["response"].get("factors", {})
|
12 |
+
dosha_present = data["response"].get("is_dosha_present", False)
|
13 |
+
bot_response = data["response"].get("bot_response", "No information available")
|
14 |
+
score = data["response"].get("score", "N/A")
|
15 |
+
|
16 |
+
readable_response = f"""
|
17 |
+
**Mangal Dosh Analysis for {name}:**
|
18 |
+
|
19 |
+
**Dosha Presence:** {'Yes' if dosha_present else 'No'}
|
20 |
+
**Score:** {score}%
|
21 |
+
|
22 |
+
**Detailed Analysis:**
|
23 |
+
- **Moon Influence:** {factors.get('moon', 'Not mentioned')}
|
24 |
+
- **Saturn Influence:** {factors.get('saturn', 'Not mentioned')}
|
25 |
+
- **Rahu Influence:** {factors.get('rahu', 'Not mentioned')}
|
26 |
+
|
27 |
+
**Astrological Suggestion:** {bot_response}
|
28 |
+
|
29 |
+
"""
|
30 |
+
return readable_response
|
31 |
+
else:
|
32 |
+
return "Invalid response from API. Please check input values."
|
33 |
+
else:
|
34 |
+
return f"Error fetching data: {response.status_code}"
|
35 |
+
|
36 |
+
with gr.Blocks() as demo:
|
37 |
+
gr.Markdown("# Mangal Dosh Checker 🪐")
|
38 |
+
gr.Markdown("Enter your details to check for Mangal Dosh:")
|
39 |
+
|
40 |
+
name = gr.Textbox(label="Name")
|
41 |
+
dob = gr.Textbox(label="Date of Birth (DD/MM/YYYY)")
|
42 |
+
tob = gr.Textbox(label="Time of Birth (HH:MM)")
|
43 |
+
lat = gr.Number(label="Latitude")
|
44 |
+
lon = gr.Number(label="Longitude")
|
45 |
+
tz = gr.Number(label="Time Zone (e.g., 5.5)")
|
46 |
+
api_key = gr.Textbox(label="API Key", type="password")
|
47 |
+
|
48 |
+
submit_btn = gr.Button("Check Mangal Dosh")
|
49 |
+
result = gr.Markdown()
|
50 |
+
|
51 |
+
submit_btn.click(check_mangal_dosh, inputs=[name, dob, tob, lat, lon, tz, api_key], outputs=result)
|
52 |
+
|
53 |
+
demo.launch()
|