Beispiel #1
0
def getHtml(ts, request):

	lat = "40.74"
	lon = "-74"
	position = geo.get_pos(request.remote_addr)
#	lat = position[0]
#	lon = position[1]
	rad = "25"
	lim = "2"
	markers = []
	img = ""
	nums = []
	lata = []
	long = []
	ret = [img,nums,lat,lon]
	for tag in ts:
		tag = tag.replace(" ","%20")
		url = "https://api.hyperpublic.com/api/v1/places?lat="+lat+"&lon="+lon+"&radius="+rad+"&limit="+lim+"&tags="+tag+"&client_id="+settings.HYPE_CLIENT_ID+"&client_secret="+settings.HYPE_CLIENT_SECRET
		data = urlfetch.fetch(url, validate_certificate=False)
		if data.status_code == 200:
			places = json.loads(data.content)
			for place in places:
				if place["locations"][0]["lat"] and place["locations"][0]["lon"] :
					lata.append(place["locations"][0]["lat"])
					long.append(place["locations"][0]["lon"])
					nums.append(place["phone_number"])
					latLon = place["locations"][0]["lat"] + "," + place["locations"][0]["lon"]
					markers.append(latLon)
	string = "%7C".join(markers)
#	ret[0] = '<img src="http://maps.google.com/maps/api/staticmap?center='+lat+','+lon+'&zoom=12&size=400x400&sensor=false&markers=color:blue%7Clabel:H%7C'+ string+'" />'
	ret[0] = string
	ret[1] = nums
	ret[2] = lata
	ret[3] = long
	return ret
Beispiel #2
0
def main():

    lat = 40.74
    lon = -74.0
    rad = 300

    ret = [lat, lon]

    position = geo.get_pos(request.remote_addr)
    #	lat = position[0]
    #	lon = position[1]
    urlfetch.fetch('http://hunch.com/authorize/v1/?appid=3145664')
    #	ret = "The map below shows places that Dealocos thinks your going to like :) <BR/>"
    #	ret = ret + "Below the map is a list of deals in your area that Dealocos thinks your going to like<BR/>"
    tags = []
    ts = hunch.get_tags()
    for tagLS in ts:
        for tag in tagLS:
            tags.append(tag)

    hypRet = hyper.getHtml(tags, request)
    yipRet = yipit_attempt.request_deals(lat, lon, rad, tags)

    #	ret = ret + hypRet[0] +"<BR/>"
    #	ret = ret + str(yipit_attempt.request_deals(lat, lon , rad , tags))+"<BR/>"
    markers = []
    #	for hypNum in hypRet[1]:
    #		for yipNum in yipRet[0]:
    #			if hypNum == yipNum[1]:
    #				latLon = hypNum[2] + "," + hypNum[3]
    #				markers.append(latLon)
    string = "%7C".join(yipRet)
    ret.append(hypRet[0])
    #	ret.append(string)
    ret.append(hypRet[0])
    #	ret = ret + '<img src="http://maps.google.com/maps/api/staticmap?center='+str(lat)+','+str(lon)+'&zoom=12&size=400x400&sensor=false&markers=color:blue%7Clabel:H%7C'+ string+'" /><BR/>'
    return render_template('index.html', ret=ret)
Beispiel #3
0
def getHtml(ts, request):

    lat = "40.74"
    lon = "-74"
    position = geo.get_pos(request.remote_addr)
    #	lat = position[0]
    #	lon = position[1]
    rad = "25"
    lim = "2"
    markers = []
    img = ""
    nums = []
    lata = []
    long = []
    ret = [img, nums, lat, lon]
    for tag in ts:
        tag = tag.replace(" ", "%20")
        url = "https://api.hyperpublic.com/api/v1/places?lat=" + lat + "&lon=" + lon + "&radius=" + rad + "&limit=" + lim + "&tags=" + tag + "&client_id=" + settings.HYPE_CLIENT_ID + "&client_secret=" + settings.HYPE_CLIENT_SECRET
        data = urlfetch.fetch(url, validate_certificate=False)
        if data.status_code == 200:
            places = json.loads(data.content)
            for place in places:
                if place["locations"][0]["lat"] and place["locations"][0][
                        "lon"]:
                    lata.append(place["locations"][0]["lat"])
                    long.append(place["locations"][0]["lon"])
                    nums.append(place["phone_number"])
                    latLon = place["locations"][0]["lat"] + "," + place[
                        "locations"][0]["lon"]
                    markers.append(latLon)
    string = "%7C".join(markers)
    #	ret[0] = '<img src="http://maps.google.com/maps/api/staticmap?center='+lat+','+lon+'&zoom=12&size=400x400&sensor=false&markers=color:blue%7Clabel:H%7C'+ string+'" />'
    ret[0] = string
    ret[1] = nums
    ret[2] = lata
    ret[3] = long
    return ret
Beispiel #4
0
def main():

    lat = 40.74
    lon = -74.0
    rad = 300

    ret = [lat, lon]

    position = geo.get_pos(request.remote_addr)
    # 	lat = position[0]
    # 	lon = position[1]
    urlfetch.fetch("http://hunch.com/authorize/v1/?appid=3145664")
    # 	ret = "The map below shows places that Dealocos thinks your going to like :) <BR/>"
    # 	ret = ret + "Below the map is a list of deals in your area that Dealocos thinks your going to like<BR/>"
    tags = []
    ts = hunch.get_tags()
    for tagLS in ts:
        for tag in tagLS:
            tags.append(tag)

    hypRet = hyper.getHtml(tags, request)
    yipRet = yipit_attempt.request_deals(lat, lon, rad, tags)

    # 	ret = ret + hypRet[0] +"<BR/>"
    # 	ret = ret + str(yipit_attempt.request_deals(lat, lon , rad , tags))+"<BR/>"
    markers = []
    # 	for hypNum in hypRet[1]:
    # 		for yipNum in yipRet[0]:
    # 			if hypNum == yipNum[1]:
    # 				latLon = hypNum[2] + "," + hypNum[3]
    # 				markers.append(latLon)
    string = "%7C".join(yipRet)
    ret.append(hypRet[0])
    # 	ret.append(string)
    ret.append(hypRet[0])
    # 	ret = ret + '<img src="http://maps.google.com/maps/api/staticmap?center='+str(lat)+','+str(lon)+'&zoom=12&size=400x400&sensor=false&markers=color:blue%7Clabel:H%7C'+ string+'" /><BR/>'
    return render_template("index.html", ret=ret)
Beispiel #5
0
def test():
    data = geo.get_pos(request.remote_addr)
    return str(data)