Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
-
from geopy.geocoders import Nominatim
|
4 |
|
5 |
API_KEY = "d6cf6f2e-301e-5f63-a988-b0a3aefd0896"
|
6 |
|
7 |
-
# Initialize Geolocator
|
8 |
-
geolocator = Nominatim(user_agent="astrology_checker")
|
9 |
-
|
10 |
-
# Function to fetch latitude and longitude based on location
|
11 |
-
def get_lat_lon(location):
|
12 |
-
location_info = geolocator.geocode(location)
|
13 |
-
if location_info:
|
14 |
-
lat = location_info.latitude
|
15 |
-
lon = location_info.longitude
|
16 |
-
return lat, lon
|
17 |
-
else:
|
18 |
-
return 0, 0
|
19 |
-
|
20 |
# Function to fetch astrology data
|
21 |
def fetch_astrology_data(endpoint, dob, tob, lat, lon, tz):
|
22 |
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"
|
@@ -32,11 +18,7 @@ def fetch_astrology_data(endpoint, dob, tob, lat, lon, tz):
|
|
32 |
return f"Error fetching data: {response.status_code} - {response.text}"
|
33 |
|
34 |
# Function to check Dosha
|
35 |
-
def check_dosha(dosha_type, name, dob, tob,
|
36 |
-
lat, lon = get_lat_lon(location)
|
37 |
-
if lat is None or lon is None:
|
38 |
-
return gr.Markdown("Location not found. Please check the location and try again.")
|
39 |
-
|
40 |
response = fetch_astrology_data(f"dosha/{dosha_type}", dob, tob, lat, lon, tz)
|
41 |
if isinstance(response, str):
|
42 |
return gr.Markdown(response)
|
@@ -64,11 +46,7 @@ def check_dosha(dosha_type, name, dob, tob, location, tz):
|
|
64 |
return gr.Markdown(readable_response)
|
65 |
|
66 |
# Function to check Dasha
|
67 |
-
def check_dasha(dasha_type, name, dob, tob,
|
68 |
-
lat, lon = get_lat_lon(location)
|
69 |
-
if lat is None or lon is None:
|
70 |
-
return gr.Markdown("Location not found. Please check the location and try again.")
|
71 |
-
|
72 |
response = fetch_astrology_data(f"dashas/{dasha_type}", dob, tob, lat, lon, tz)
|
73 |
if isinstance(response, str):
|
74 |
return gr.Markdown(response)
|
@@ -92,7 +70,7 @@ def check_dasha(dasha_type, name, dob, tob, location, tz):
|
|
92 |
|
93 |
return gr.Markdown(readable_response)
|
94 |
|
95 |
-
# Gradio UI with
|
96 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
97 |
gr.Markdown("# 🪐 Astrology Checker - Find Your Dosha & Dasha 🪐")
|
98 |
|
@@ -102,15 +80,15 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
102 |
tob = gr.Textbox(label="Time of Birth (HH:MM)", placeholder="11:40")
|
103 |
|
104 |
with gr.Row():
|
105 |
-
|
|
|
106 |
tz = gr.Number(label="Timezone (e.g., 5.5 for India)", value=5.5)
|
107 |
|
108 |
result = gr.Markdown()
|
109 |
-
|
110 |
-
# Function to create a button with dosha_type as gr.State
|
111 |
def create_button(label, dosha_type, fn):
|
112 |
-
return gr.Button(label, variant="primary").click(fn, inputs=[name, dob, tob,
|
113 |
-
|
114 |
gr.Markdown("## 🌟 Dosha Analysis")
|
115 |
with gr.Row():
|
116 |
create_button("Mangal Dosh", "mangal-dosh", check_dosha)
|
@@ -125,6 +103,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
125 |
create_button("Mahadasha Predictions", "maha-dasha-predictions", check_dasha)
|
126 |
create_button("Antardasha", "antar-dasha", check_dasha)
|
127 |
create_button("Char Dasha Current", "char-dasha-current", check_dasha)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
gr.Markdown("### 🔍 Enter your details above and click the relevant button to analyze your astrology report!")
|
130 |
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
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"
|
|
|
18 |
return f"Error fetching data: {response.status_code} - {response.text}"
|
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):
|
24 |
return gr.Markdown(response)
|
|
|
46 |
return gr.Markdown(readable_response)
|
47 |
|
48 |
# Function to check Dasha
|
49 |
+
def check_dasha(dasha_type, name, dob, tob, lat, lon, tz):
|
|
|
|
|
|
|
|
|
50 |
response = fetch_astrology_data(f"dashas/{dasha_type}", dob, tob, lat, lon, tz)
|
51 |
if isinstance(response, str):
|
52 |
return gr.Markdown(response)
|
|
|
70 |
|
71 |
return gr.Markdown(readable_response)
|
72 |
|
73 |
+
# Gradio UI with improvements
|
74 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
75 |
gr.Markdown("# 🪐 Astrology Checker - Find Your Dosha & Dasha 🪐")
|
76 |
|
|
|
80 |
tob = gr.Textbox(label="Time of Birth (HH:MM)", placeholder="11:40")
|
81 |
|
82 |
with gr.Row():
|
83 |
+
lat = gr.Number(label="Latitude", value=11)
|
84 |
+
lon = gr.Number(label="Longitude", value=77)
|
85 |
tz = gr.Number(label="Timezone (e.g., 5.5 for India)", value=5.5)
|
86 |
|
87 |
result = gr.Markdown()
|
88 |
+
|
|
|
89 |
def create_button(label, dosha_type, fn):
|
90 |
+
return gr.Button(label, variant="primary").click(fn, inputs=[gr.State(dosha_type), name, dob, tob, lat, lon, tz], outputs=result)
|
91 |
+
|
92 |
gr.Markdown("## 🌟 Dosha Analysis")
|
93 |
with gr.Row():
|
94 |
create_button("Mangal Dosh", "mangal-dosh", check_dosha)
|
|
|
103 |
create_button("Mahadasha Predictions", "maha-dasha-predictions", check_dasha)
|
104 |
create_button("Antardasha", "antar-dasha", check_dasha)
|
105 |
create_button("Char Dasha Current", "char-dasha-current", check_dasha)
|
106 |
+
create_button("Char Dasha Main", "char-dasha-main", check_dasha)
|
107 |
+
create_button("Char Dasha Sub", "char-dasha-sub", check_dasha)
|
108 |
+
create_button("Current Mahadasha Full", "current-mahadasha-full", check_dasha)
|
109 |
+
create_button("Current Mahadasha", "current-mahadasha", check_dasha)
|
110 |
+
create_button("Paryantar Dasha", "paryantar-dasha", check_dasha)
|
111 |
+
create_button("Specific Dasha", "specific-sub-dasha", check_dasha)
|
112 |
+
create_button("Yogini Dasha Main", "yogini-dasha-main", check_dasha)
|
113 |
+
create_button("Yogini Dasha Sub", "yogini-dasha-sub", check_dasha)
|
114 |
|
115 |
gr.Markdown("### 🔍 Enter your details above and click the relevant button to analyze your astrology report!")
|
116 |
|