forked from OIM3640/MBTA-Web-App-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (24 loc) · 813 Bytes
/
app.py
File metadata and controls
34 lines (24 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from flask import Flask, render_template, request
import mbta_helper
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/nearest_mbta", methods=["POST"])
def nearest_mbta():
place_name = request.form.get("place_name", "").strip()
if not place_name:
return render_template("error.html", message="Please enter a location."), 400
try:
station, accessible, temp_f = mbta_helper.find_stop_near(place_name)
except Exception as exc:
return render_template("error.html", message=str(exc)), 500
return render_template(
"mbta_station.html",
place_name=place_name,
station=station,
accessible=accessible,
temp_f=temp_f,
)
if __name__ == "__main__":
app.run(debug=True)