예제 #1
0
def setPrefs():
    prefs = request.form.getlist("preference")
    d={
        "Italian":False,
        "French":False,
        "Chinese":False,
        "Japanese":False,
        "Spanish":False,
        "Fast":False,
        "Dessert":False,
        "Ethiopian":False,
        "Middle-Eastern":False,
        "Polish":False,
        "Thai":False,
        "Caribbean":False}
    
    for pref in prefs:
        d[pref]=True
    utils.updatePrefs(session["username"],d)
    return redirect("/profile")
예제 #2
0
 print request.form.get("pref","")==""
 start = request.form.get("start","")
 end = request.form.get("end","")
 print(start)
 print(end)
 #fields were left blank
 if start == None or end == None:
     return render_template("route.html", error=1)
 stationList = hopstopScraper.getRoutes(start, end)
 results = []
 stations= []
 if request.form.get("pref","") != "":
     pref = request.form.get("pref","")
     oldprefs = utils.getPrefs(session["username"])
     oldprefs[pref]=True
     utils.updatePrefs(session["username"],oldprefs)
 elif request.form.get("pref2","") != "":
     pref = request.form.get("pref","")
 else: 
     pref = "food"
 for station in stationList: 
     print station
     print pref
     try: 
         yelplist = yelp.search(pref,station)
         results.append(yelplist)
         stations.append(station)
     except KeyError:
         print "Yelp did not find any matches for this station"    
 print results
 session["stations"]= stations