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 )
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')
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)
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")
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)
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")
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')
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')
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')
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')
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')
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")
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)
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)
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)
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'))
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)
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')
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)
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)
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])
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)
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)
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)
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")
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')
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])
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)
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)
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)