Skip to content

Commit 8db3a4d

Browse files
committed
Fixing area id....like a boss
1 parent 4f0c00b commit 8db3a4d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/food.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ def foodpanda(lat=0, lng=0, id=0):
66
'X-FP-API-KEY': 'android'
77
}
88
if id == 0:
9+
print id, "========================="
910
url = 'http://api.foodpanda.in/api/v4/areas/geocoding_reverse?latitude='+str(lat)+'&longitude='+str(lng)+'&limit=1'
1011
r = requests.get(url, headers=headers)
11-
data = r.json()['data']['items'][0]['main_area']['id']
12+
data_id = r.json()['data']['items'][0]['main_area']['id']
1213
#print data
13-
url_new = 'http://api.foodpanda.in/api/v4/vendors?area_id=' + str(data)
14+
url_new = 'http://api.foodpanda.in/api/v4/vendors?area_id=' + str(data_id)
1415
r = requests.get(url_new, headers=headers)
15-
data = r.json()['data']['items']
16-
return json.dumps(data)
16+
data = r.json()['data']
17+
restData = {}
18+
restData['restaurants'] = data['items']
19+
restData['area_id'] = str(data_id)
20+
return json.dumps(restData)
1721
else:
1822
url_new = 'http://api.foodpanda.in/api/v4/vendors?area_id=' + str(id)
1923
r = requests.get(url_new, headers=headers)

0 commit comments

Comments
 (0)