Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
|
|
4 |
import pandas as pd
|
5 |
|
6 |
# Google Maps API Key (replace with your actual key)
|
7 |
-
api_key = "
|
8 |
|
9 |
# Google Places API endpoints
|
10 |
url = "https://maps.googleapis.com/maps/api/place/textsearch/json"
|
@@ -25,8 +25,10 @@ def get_places_data(query, location, radius, next_page_token=None):
|
|
25 |
response = requests.get(url, params=params)
|
26 |
|
27 |
if response.status_code == 200:
|
|
|
28 |
return response.json()
|
29 |
else:
|
|
|
30 |
return None
|
31 |
|
32 |
# Function to fetch detailed information for a specific place using its place_id
|
@@ -38,6 +40,7 @@ def get_place_details(place_id):
|
|
38 |
response = requests.get(places_details_url, params=params)
|
39 |
|
40 |
if response.status_code == 200:
|
|
|
41 |
details_data = response.json().get("result", {})
|
42 |
return {
|
43 |
"name": details_data.get("name", ""),
|
@@ -46,6 +49,7 @@ def get_place_details(place_id):
|
|
46 |
"website": details_data.get("website", "")
|
47 |
}
|
48 |
else:
|
|
|
49 |
return {}
|
50 |
|
51 |
# Function to fetch all places data including pagination
|
|
|
4 |
import pandas as pd
|
5 |
|
6 |
# Google Maps API Key (replace with your actual key)
|
7 |
+
api_key = "GOOGLE_MAPS_API_KEY"
|
8 |
|
9 |
# Google Places API endpoints
|
10 |
url = "https://maps.googleapis.com/maps/api/place/textsearch/json"
|
|
|
25 |
response = requests.get(url, params=params)
|
26 |
|
27 |
if response.status_code == 200:
|
28 |
+
print("Places data response:", response.json()) # Logging the response
|
29 |
return response.json()
|
30 |
else:
|
31 |
+
print("Error fetching places data:", response.text) # Logging any errors
|
32 |
return None
|
33 |
|
34 |
# Function to fetch detailed information for a specific place using its place_id
|
|
|
40 |
response = requests.get(places_details_url, params=params)
|
41 |
|
42 |
if response.status_code == 200:
|
43 |
+
print("Place details response:", response.json()) # Logging the response
|
44 |
details_data = response.json().get("result", {})
|
45 |
return {
|
46 |
"name": details_data.get("name", ""),
|
|
|
49 |
"website": details_data.get("website", "")
|
50 |
}
|
51 |
else:
|
52 |
+
print("Error fetching place details:", response.text) # Logging any errors
|
53 |
return {}
|
54 |
|
55 |
# Function to fetch all places data including pagination
|