-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetBars.py
56 lines (38 loc) · 1.44 KB
/
getBars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'''
Created on Apr 12, 2014
@author: Rishi Josan
'''
from flask import Flask
from flask import request, jsonify
import foursquare
import json
loc = '/media/sf_G_DRIVE/sharedWorkspace/protoKrawl/json/'
app = Flask(__name__ ,static_url_path='')
#client = foursquare.Foursquare(client_id='ETWY3CHBMEFXU2DZZZ1DKTO2YPMNKJWNZTVSKBABBXTQEDW2', client_secret='X0H2FBGJ53ANMC23YHWQKI0LV5I52F12MWZMF5002EOJ0NSR', redirect_uri='http://127.0.0.1:5000/')
@app.route("/")
def hello():
return "Hello World!"
@app.route("/getVenue" , methods=["GET", "POST"])
def getVenue():
if request.method == "GET":
#reqParams = request.get_json()
reqParams = request.args
lat = reqParams['lat']
lon = reqParams['lon']
#print str(lat+', '+lon)
client = foursquare.Foursquare(client_id='ETWY3CHBMEFXU2DZZZ1DKTO2YPMNKJWNZTVSKBABBXTQEDW2', client_secret='X0H2FBGJ53ANMC23YHWQKI0LV5I52F12MWZMF5002EOJ0NSR')
srch = client.venues.explore(params={'ll': str(lat+', '+lon), 'section' : 'drinks' , 'limit' : 10 })
locations = srch['groups'][0]['items']
locList = dict()
n=0
for item in locations:
locList[n]=item['venue']
n+=1
#result = json.dumps(locList)
return jsonify(locList)
@app.route('/crawl')
def crawl():
return app.send_static_file('index.html')
if __name__ == "__main__":
#app.debug = True
app.run()