Example #1
0
def restaurants():
    if request.method == "POST":
        form = request.form
        details = form["details"]
        session["details"] = details
        details = [c.strip() for c in details.strip().strip(",").split(";")]
        # address radius ratings categories
        address = details[0]
        radius = int(details[1]) * 1609
        rating = details[2]
        types = [d.strip() for d in details[3].split(",")]
        session["setrad"] = details[1]
        session["setrating"] = rating
        session["addr"] = address
        if "types" in session:
            session["types"] += types
        else:
            session["types"] = types
        results = util.filter(address, radius, types, rating)
        cats = util.getTypes(address, radius)
        i = 0
        while i < len(cats):
            if cats[i] in session["types"]:
                cats.pop(i)
            else:
                i += 1
        for result in results:
            result["category"] = catformat(result["category"])
        return render_template("restaurants.html", results=results, categories=cats)
    return redirect("/index")
Example #2
0
def restaurants():
    if request.method == "POST":
        form = request.form
        details = form['details']
        session['details'] = details
        details = [c.strip() for c in details.strip().strip(',').split(';')]
        #address radius ratings categories
        address = details[0]
        radius = int(details[1]) * 1609
        rating = details[2]
        types = [d.strip() for d in details[3].split(',')]
        session['setrad'] = details[1]
        session['setrating'] = rating
        session['addr'] = address
        if 'types' in session:
            session['types'] += types
        else:
            session['types'] = types
        results = util.filter(address, radius, types, rating)
        cats = util.getTypes(address, radius)
        i = 0
        while i < len(cats):
            if cats[i] in session['types']:
                cats.pop(i)
            else:
                i += 1
        for result in results:
            result['category'] = catformat(result['category'])
        return render_template(
            'restaurants.html', results=results, categories=cats)
    return redirect('/index')
Example #3
0
def restaurants():
    if request.method == "POST":
        form = request.form
        details = form['details']
        session['details'] = details
        details = [c.strip() for c in details.strip().strip(',').split(';')]
        #address radius ratings categories
        address = details[0]
        radius = int(details[1]) * 1609
        rating = details[2]
        types = [d.strip() for d in details[3].split(',')]
        session['setrad'] = details[1]
        session['setrating'] = rating
        session['addr'] = address
        if 'types' in session:
            session['types'] += types
        else:
            session['types'] = types
        results = util.filter(address, radius, types, rating)
        cats = util.getTypes(address, radius)
        i = 0
        while i < len(cats):
            if cats[i] in session['types']:
                cats.pop(i)
            else:
                i += 1
        for result in results:
            result['category'] = catformat(result['category'])
        return render_template('restaurants.html',
                               results=results,
                               categories=cats)
    return redirect('/index')
Example #4
0
def results():
    args = request.args
    addr = args.get("addr")
    result = util.getTypes(addr)
    return jsonify(result=result)
Example #5
0
def results():
    args = request.args
    addr = args.get('addr')
    result = util.getTypes(addr)
    return jsonify(result=result)