Exemple #1
0
def nearest():
    placeName = request.form['Pname']
    try:
        nearestStop = find_stop_near(placeName)
    except IndexError:
        return render_template('errorPage.html')
    return nearestStop
Exemple #2
0
def find():
    # modify this function so it renders different templates for POST and GET method.
    # aka. it displays the form when the method is 'GET'; it displays the results when
    # the method is 'POST' and the data is correctly processed.
    if request.method == "POST":
        requestedplace = str(request.form["place"])
        requestedstop = find_stop_near(requestedplace)
        if requestedstop:
            return render_template("found.html",
                                   requestedstop=requestedstop,
                                   requestedplace=requestedplace)
        else:
            return render_template("find.html", error=True)
    return render_template("find.html", error=None)
Exemple #3
0
def home():
    if request.method == "POST":
        place = request.form["b"]
        if place == "":
            return render_template("index.html")

        station_name, wheelchair_boarding = find_stop_near(place)

        if station_name != "False":
            return redirect(
                url_for("result", sn=station_name, wb=wheelchair_boarding))
        else:
            return redirect(url_for("error"))

    return render_template("index.html")
Exemple #4
0
def find():
    # modify this function so it renders different templates for POST and GET method.
    # aka. it displays the form when the method is 'GET'; it displays the results when
    # the method is 'POST' and the data is correctly processed.
    if request.method == 'POST':
        place_name = request.form['place']
        station_name, wheelchair_boarding = find_stop_near(place_name)

        if station_name:
            return render_template("result.html",
                                   place_name=place,
                                   station_name=station_name,
                                   wheelchair_boarding=wheelchair_boarding)
        else:
            return render_template('form.html', error=True)
    return render_template('form.html', error=None)
import mbta_finder

print mbta_finder.find_stop_near('Fenway Park')