Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import requests
|
|
3 |
|
4 |
API_KEY = "d6cf6f2e-301e-5f63-a988-b0a3aefd0896"
|
5 |
|
|
|
6 |
def fetch_astrology_data(endpoint, dob, tob, lat, lon, tz):
|
7 |
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"
|
8 |
response = requests.get(url)
|
@@ -16,6 +17,7 @@ def fetch_astrology_data(endpoint, dob, tob, lat, lon, tz):
|
|
16 |
else:
|
17 |
return f"Error fetching data: {response.status_code}"
|
18 |
|
|
|
19 |
def check_dosha(dosha_type, name, dob, tob, lat, lon, tz):
|
20 |
response = fetch_astrology_data(f"dosha/{dosha_type}", dob, tob, lat, lon, tz)
|
21 |
if isinstance(response, str):
|
@@ -27,7 +29,7 @@ def check_dosha(dosha_type, name, dob, tob, lat, lon, tz):
|
|
27 |
score = response.get("score", "N/A")
|
28 |
|
29 |
readable_response = f"""
|
30 |
-
|
31 |
|
32 |
**Dosha Presence:** {'Yes' if dosha_present else 'No'}
|
33 |
**Score:** {score}%
|
@@ -41,31 +43,34 @@ def check_dosha(dosha_type, name, dob, tob, lat, lon, tz):
|
|
41 |
"""
|
42 |
return readable_response
|
43 |
|
|
|
44 |
def check_dasha(dasha_type, name, dob, tob, lat, lon, tz):
|
45 |
response = fetch_astrology_data(f"dashas/{dasha_type}", dob, tob, lat, lon, tz)
|
46 |
if isinstance(response, str):
|
47 |
return response
|
48 |
|
49 |
-
return f"
|
50 |
|
51 |
-
|
52 |
-
|
|
|
53 |
|
54 |
with gr.Row():
|
55 |
-
name = gr.Textbox(label="Name")
|
56 |
-
dob = gr.Textbox(label="DOB (DD/MM/YYYY)")
|
57 |
-
tob = gr.Textbox(label="Time (HH:MM)")
|
58 |
|
59 |
with gr.Row():
|
60 |
-
lat = gr.Number(label="Latitude")
|
61 |
-
lon = gr.Number(label="Longitude")
|
62 |
-
tz = gr.Number(label="Time Zone")
|
63 |
|
64 |
result = gr.Markdown()
|
65 |
|
66 |
def create_button(label, dosha_type, fn):
|
67 |
-
return gr.Button(label).click(fn, inputs=[gr.State(dosha_type), name, dob, tob, lat, lon, tz], outputs=result)
|
68 |
|
|
|
69 |
with gr.Row():
|
70 |
create_button("Mangal Dosh", "mangal-dosh", check_dosha)
|
71 |
create_button("Kaalsarp Dosh", "kaalsarp-dosh", check_dosha)
|
@@ -73,10 +78,12 @@ with gr.Blocks() as demo:
|
|
73 |
create_button("Pitra Dosh", "pitra-dosh", check_dosha)
|
74 |
create_button("Papasamaya", "papasamaya", check_dosha)
|
75 |
|
|
|
76 |
with gr.Row():
|
77 |
create_button("Mahadasha", "maha-dasha", check_dasha)
|
78 |
create_button("Mahadasha Predictions", "maha-dasha-predictions", check_dasha)
|
79 |
create_button("Antardasha", "antar-dasha", check_dasha)
|
80 |
create_button("Char Dasha Current", "char-dasha-current", check_dasha)
|
81 |
|
|
|
82 |
demo.launch()
|
|
|
3 |
|
4 |
API_KEY = "d6cf6f2e-301e-5f63-a988-b0a3aefd0896"
|
5 |
|
6 |
+
# Function to fetch astrology data
|
7 |
def fetch_astrology_data(endpoint, dob, tob, lat, lon, tz):
|
8 |
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"
|
9 |
response = requests.get(url)
|
|
|
17 |
else:
|
18 |
return f"Error fetching data: {response.status_code}"
|
19 |
|
20 |
+
# Function to check dosha
|
21 |
def check_dosha(dosha_type, name, dob, tob, lat, lon, tz):
|
22 |
response = fetch_astrology_data(f"dosha/{dosha_type}", dob, tob, lat, lon, tz)
|
23 |
if isinstance(response, str):
|
|
|
29 |
score = response.get("score", "N/A")
|
30 |
|
31 |
readable_response = f"""
|
32 |
+
### {dosha_type.replace('-', ' ').title()} Analysis for {name}
|
33 |
|
34 |
**Dosha Presence:** {'Yes' if dosha_present else 'No'}
|
35 |
**Score:** {score}%
|
|
|
43 |
"""
|
44 |
return readable_response
|
45 |
|
46 |
+
# Function to check dasha
|
47 |
def check_dasha(dasha_type, name, dob, tob, lat, lon, tz):
|
48 |
response = fetch_astrology_data(f"dashas/{dasha_type}", dob, tob, lat, lon, tz)
|
49 |
if isinstance(response, str):
|
50 |
return response
|
51 |
|
52 |
+
return f"### {dasha_type.replace('-', ' ').title()} Analysis for {name}\n\n" + str(response)
|
53 |
|
54 |
+
# Gradio UI with improvements
|
55 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
56 |
+
gr.Markdown("# 🪐 Astrology Checker - Find Your Dosha & Dasha 🪐")
|
57 |
|
58 |
with gr.Row():
|
59 |
+
name = gr.Textbox(label="Name", placeholder="Enter your name")
|
60 |
+
dob = gr.Textbox(label="DOB (DD/MM/YYYY)", placeholder="21/04/2021")
|
61 |
+
tob = gr.Textbox(label="Time (HH:MM)", placeholder="11:40")
|
62 |
|
63 |
with gr.Row():
|
64 |
+
lat = gr.Number(label="Latitude", placeholder="11")
|
65 |
+
lon = gr.Number(label="Longitude", placeholder="77")
|
66 |
+
tz = gr.Number(label="Time Zone", placeholder="5.5")
|
67 |
|
68 |
result = gr.Markdown()
|
69 |
|
70 |
def create_button(label, dosha_type, fn):
|
71 |
+
return gr.Button(label, variant="primary").click(fn, inputs=[gr.State(dosha_type), name, dob, tob, lat, lon, tz], outputs=result)
|
72 |
|
73 |
+
gr.Markdown("## 🌟 Dosha Analysis")
|
74 |
with gr.Row():
|
75 |
create_button("Mangal Dosh", "mangal-dosh", check_dosha)
|
76 |
create_button("Kaalsarp Dosh", "kaalsarp-dosh", check_dosha)
|
|
|
78 |
create_button("Pitra Dosh", "pitra-dosh", check_dosha)
|
79 |
create_button("Papasamaya", "papasamaya", check_dosha)
|
80 |
|
81 |
+
gr.Markdown("## 🔮 Dasha Analysis")
|
82 |
with gr.Row():
|
83 |
create_button("Mahadasha", "maha-dasha", check_dasha)
|
84 |
create_button("Mahadasha Predictions", "maha-dasha-predictions", check_dasha)
|
85 |
create_button("Antardasha", "antar-dasha", check_dasha)
|
86 |
create_button("Char Dasha Current", "char-dasha-current", check_dasha)
|
87 |
|
88 |
+
gr.Markdown("### 🔍 Enter your details above and click the relevant button to analyze your astrology report!")
|
89 |
demo.launch()
|