コード例 #1
0
def indext():
    if request.method == "POST":
        location = str(request.form["location"])
        stop = find_stop_near(location)[0]
        acc = find_stop_near(location)[1]
        if acc == 1:
            acc = "Yes"
        elif acc == 2:
            acc = "No"
        else:
            acc = "Unknown"
        schedule = get_schedule(location)
        distance = get_distance(location)

        if stop:
            return render_template(
                "nearest.html", 
                location = location, 
                stop = stop,
                acc = acc,
                schedule = schedule,
                distance = distance 
            )
        else:
            return render_template(
                "index.html",
                error = True
            )
    return render_template(
        "index.html",
        error = None
    )
コード例 #2
0
def data():
    '''
    Get the input place name or address. Check if search work or not by calling find_stop_near() function.
    If works, redirect page to process() fuction at the route /nearest_mbta, using POST method at the route /nearest
    If not work, display error page using error.html
    '''
    place_name = request.form['text']
    session['place_name'] = place_name
    try:
        find_stop_near(place_name)
        return redirect(url_for('process'))
    except:
        return render_template('error.html')
コード例 #3
0
def station():
    '''
    Identify the closest station.
    '''
    if request.method == "POST":
        place = request.form["Location"]
        ID, station_name, wheelchair_accessible = find_stop_near(place)
        history = History(location=id,
                          mbta=station_name,
                          accessible=wheelchair_accessible)

        try:
            db.session.add(history)
            db.session.commit()
            return render_template("mbtaresult.html",
                                   Location=place,
                                   station_name=station_name,
                                   wheelchair_accessible=wheelchair_accessible)
        except:
            return "There was an issue adding your location"

        if station_name:
            return render_template("mbtaresult.html",
                                   Location=place,
                                   station_name=station_name,
                                   wheelchair_accessible=wheelchair_accessible)
        else:
            return render_template('mbtaform.html', error=True)
    else:
        history = History.query.order_by(History.date_created).all()
        return render_template("mbtaform.html", error=None)
コード例 #4
0
ファイル: app.py プロジェクト: MateosNorian/WebApp-MBTA
def index():
    map_key, search_key = mbta_helper.get_keys()
    try:
        if request.method == "POST":
            place_name = request.form["place_name"]
            distance = int(request.form["distance"])
            wheelchair_required = request.form["wheelchair"]
            lat, lng = mbta_helper.get_lat_long(place_name)
            stop_name, wheelchair = mbta_helper.find_stop_near(
                place_name, distance, wheelchair_required)
            return render_template(
                "index.html",
                place_name=place_name,
                stop_name=stop_name,
                wheelchair=wheelchair,
                lat=lat,
                lng=lng,
                map_key=map_key,
                search_key=search_key,
            )
        return render_template(
            "index.html",
            place_name=False,
            lat=42.3601,
            lng=-71.0589,
            map_key=map_key,
            search_key=search_key,
        )
    except:
        return render_template("error.html")
コード例 #5
0
def calculate():
    if request.method == 'POST':
        place_name = request.form['place_name']
        stop, distance, first_time = find_stop_near(place_name)
        return render_template('result.html', stop= stop, distance=distance, first_time=first_time)
    else:
        return render_template('index.html', error=None)
コード例 #6
0
def theLocation():
    if request.method == 'POST':
        place_name = request.form["location"]
        stop, wheelchair_boarding = find_stop_near(place_name)
        return render_template("result.html", stop=stop, wheelchair= wheelchair_boarding)
    else:
        return render_template("index.html")
コード例 #7
0
ファイル: app.py プロジェクト: jlee822/WebApp-MBTA
def home():
    if request.method == "POST":
        user = request.form["location_name"]
        return render_template('data.html',
                               value=user,
                               nearest_stop=find_stop_near(user))
    else:
        return render_template('website.html')
コード例 #8
0
ファイル: app.py プロジェクト: lmendez2/WebApp_MTBA_Helper
def find_stop():
    if request.method == 'POST':
        place = request.form['userloc']
        stop, distance = find_stop_near(place)
        print(stop)
        print(distance)
        return render_template('results.html', stop = stop, distance=distance)
    return render_template('index.html')
コード例 #9
0
def hello_world():
    if request.method == 'POST':
        placeName = str(request.form["place"])
        typeTrans = str(request.form["transType"])
        ret = find_stop_near(placeName, typeTrans)
        print(ret)
        return render_template('index.html', stops=ret, placeName=placeName)
    else:
        return render_template('index.html')
コード例 #10
0
def nearest():
    """ 
        Returns any nearby MTBA stations if possible
    """
    try:
        text = find_stop_near(session["place"])
        return render_template("place.html", text=text)
    except:
        return render_template('error.html')
コード例 #11
0
def nearest():
    """ If place has a nearby MBTA, returns the page with that info,
        else (or if any other errors), returns an error page 
    """
    try:
        text = find_stop_near(session["place"])
        return render_template("place.html", text = text)
    except:
        return render_template('error.html')
コード例 #12
0
ファイル: app.py プロジェクト: asillis1/WebApp-MBTA
def get_nearest_stop():
    if request.method == "POST":
        place_name = request.form['address']
        result = mbta_helper.find_stop_near(place_name)
        if result != "Error":
            return render_template('station.html', result=result)
        else:
            return render_template("error.html")
    return render_template("index.html")
コード例 #13
0
def process():
    '''
    Get place name or address using GET method at the route /nearest_mbta
    Search for nearest station name and wheelchair accessibility information
    Return those search result through page mbta_station.html
    '''
    if request.method == 'GET':
        place_name = session.get('place_name', None)
        stop, wheelchair = find_stop_near(place_name)
        return render_template('mbta_station.html', nearest_station = stop, wheelchair_accessibility = wheelchair)
コード例 #14
0
def index():
    if request.method == 'POST':
        intad = request.form['location']
        result = find_stop_near(intad)

        if result:
            return render_template('results.html',intad=intad, result=result)
        else:
            return render_template('index.html', error=True)
    return render_template('index.html', error=None)
コード例 #15
0
ファイル: app.py プロジェクト: akgohel3/WebApp_MBTA_Helper
def index():
    if request.method == 'POST':
        place = request.form['location']
        place, distance = find_stop_near(place)

        if place and distance:
            return render_template('index.html', place=place, distance=distance)
        else:
            return render_template('index.html', error=True)
    return render_template('index.html', error=None)
コード例 #16
0
ファイル: app.py プロジェクト: nickgu20/WebApp-MBTA
def index_post():
    if request.method =="POST":
        location = request.form["location"]
        # return location
        mbta, wheelchair = find_stop_near(location)
        if mbta != "No location found":
            return render_template("return.html", mbta=mbta, wheelchair=wheelchair)
            return redirect(url_for('index.html'))
        else:
            return render_template("error.html")
            return redirect(url_for('index.html'))
コード例 #17
0
def nearest():
    if request.method == "POST":
        place_name = str(request.form["place_name"])
        mbta_stop = find_stop_near(place_name)

        if mbta_stop:
            return render_template("mbta_result.html",
                                   place_name=place_name,
                                   mbta_stop=mbta_stop)
        else:
            return render_template("mbta_form.html", error=True)
    return render_template("mbta_form.html", error=None)
コード例 #18
0
ファイル: app.py プロジェクト: ywang7-vivian/WebApp-MBTA
def form():
    if request.method == 'POST':
        place_name = request.form['place_name']
        route_type = request.form['route_type']
        try:
            station_name, wheelchair_accessibility = find_stop_near(
                place_name, route_type)
            session['station_name'] = station_name
            session['wheelchair_accessibility'] = wheelchair_accessibility
            return redirect(url_for('result'))
        except:
            return render_template('mbta_error.html')
コード例 #19
0
ファイル: app.py プロジェクト: ckennedy546x/MIS3640
def nearStation():
    if request.method == 'POST':
        address = str(request.form['address'])
        latitude, longitude = get_lat_long(address)
        stop_name, distance = find_stop_near(address)

        return render_template('station_result.html',
                               address=address,
                               latitude=latitude,
                               longitude=longitude,
                               stop_name=stop_name,
                               distance=distance)
    return render_template('address_form.html', error=None)
コード例 #20
0
def find_t():
    if request.method == "POST":
        a = str(request.form["a"])
        location, wheelchair = find_stop_near(a)

        if location:
            return render_template("t_result.html",
                                   a=a,
                                   location=location,
                                   wheelchair=wheelchair)
        else:
            return render_template("find_t.html", error=True)
    return render_template("find_t.html", error=None)
コード例 #21
0
ファイル: app.py プロジェクト: Liam-E2/WebApp-MBTA
def find_stop():
    """Triggered by HTML form, returns template for response"""
    # Extract form data
    loc = request.form['location']
    station_type = request.form['type']

    # Default no station type
    if station_type[0] == "S":
        station_type = None
    
    # Find Stop & Populate Template
    result = find_stop_near(loc, station_type=station_type)
    
    return render_template("response.html", place_name=result[0], wheelchair_accessible=result[1])
コード例 #22
0
def find():
    if request.method == "POST":
        requestedplace = str(request.form["location"])
        requestedstop = find_stop_near(requestedplace)
        if requestedstop != (None, None):
            return render_template("found.html",
                                   requestedstop=requestedstop[0],
                                   requestedplace=requestedplace,
                                   wheelchair=requestedstop[1])
        elif requestedstop == (None, None):
            return render_template("notfound.html")
        else:
            return render_template("index.html", error=True)
    return render_template("index.html", error=None)
コード例 #23
0
ファイル: app.py プロジェクト: ikim1/WebApp-MBTA
def nearest_mbta():
    if request.method == "POST":
        location = str(request.form["location"])
        station_name, wheelchair_accessible = find_stop_near(location)

        if station_name:
            return render_template("nearest_mbta_result.html",
                                   location=location,
                                   station_name=station_name,
                                   wheelchair_accessible=wheelchair_accessible)
        else:
            return render_template("nearest_mbta_form.html", error=True)

    return render_template("nearest_mbta_form.html", error=None)
コード例 #24
0
def near_station():
    if request.method == "POST":
        place_name = str(request.form["place name"])
        near_stop = find_stop_near(place_name)
        stop = near_stop[0]
        wheelchair = near_stop[1]

        if near_stop:
            return render_template("station_result.html",
                                   place_name=place_name,
                                   stop=stop,
                                   wheelchair=wheelchair)
        else:
            return render_template("station_form.html", error=True)
    return render_template("station_form.html", error=None)
コード例 #25
0
def form():
    if request.method == "POST":
        place_name = request.form.get("place_name")
        radius = request.form.get("radius")
        route_type = request.form.get("route_type")
        station_name, wheelchair_accessibility = mbta_helper.find_stop_near(
            place_name, radius, route_type)
        return render_template(
            "results.html",
            station_name=station_name,
            wheelchair_accessibility=wheelchair_accessibility,
            radius=radius,
            route_type=route_type,
            place_name=place_name)
    return render_template("welcome.html")
コード例 #26
0
def index():
    if request.method == "POST":
        address = request.form['address']

        nearest_stop = find_stop_near(address)

        if nearest_stop == "No stops nearby":
            return render_template('results.html')
        else:
            return render_template('results.html',
                                   start=address,
                                   stop_name=nearest_stop[0],
                                   stop_address=nearest_stop[1],
                                   dist=round(nearest_stop[2], 2))
    return render_template('index.html')
コード例 #27
0
ファイル: app.py プロジェクト: nandini363/Assignment-3
def find():
    """
    This function returns whether the location entered has a station nearby and if there is wheelchair accessibility
    """
    if request.method == "POST":
        place = request.form["location"]
        place = str(place)
        result = find_stop_near(place)
        if result == "MBTA Not Available":
            return render_template("notavailable.html")
        else:
            result = result.split(",")
            return render_template("available.html",
                                   location=result[0],
                                   wheelchair=result[1])
コード例 #28
0
def find():
    try:
        loc = str(request.form["location"])
        station_name, wheelchair_accessibility = find_stop_near(loc)
    except:
        return render_template("result.html", error=True)

    if station_name:  # returns result page
        return render_template(
            "result.html",
            location=loc,
            station_name=station_name,
            wheelchair_accessibility=wheelchair_accessibility,
        )
    else:  # returns error info
        return render_template("result.html", error=True)
コード例 #29
0
ファイル: app.py プロジェクト: sgriffin10/WebApp_MBTA
def find_neareststop_and_accessibility():
    """
    Given a place name or address, return the nearest MBTA stop and whether it is wheelchair accessible.
    """
    if request.method == "POST":
        place_name = request.form["place"]
        # wheelchair_boarding = str(request.form["wheelchair_boarding"])
        # print(place_name)
        stop, wheelchair_boarding = find_stop_near(place_name)

        return render_template("input_results.html",
                               stop=stop,
                               wheelchair_boarding=wheelchair_boarding)
    else:
        return render_template("input_form.html", error=True)
    return render_template("input_form.html", error=None)
コード例 #30
0
def nearest():
    if request.method == "POST":
        place_name = str(request.form['location'])
        mbta_station = find_stop_near(place_name)
        station = mbta_station[0]
        wheelchair = mbta_station[1]

        if mbta_station:
            return render_template("result.html",
                                   place_name=place_name,
                                   station=station,
                                   wheelchair=wheelchair)
        else:
            return render_template("mbta_form.html", error=True)

    return render_template("mbta_form.html", error=None)