-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
36 lines (27 loc) · 1.1 KB
/
app.py
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
35
36
from flask import Flask
from flask import render_template, url_for, request
import qld_rfs
app = Flask(__name__, static_url_path='/static/')
@app.route('/')
def home():
"""Handle home page"""
return render_template("home.html")
@app.route('/locate', methods=['POST'])
def locate():
"""Locate nearest QLD RFS station"""
street_no = request.form['street_no']
street = request.form['street']
locality = request.form['locality']
user_address = f"{street_no} {street}, {locality}"
# Find closest
geocoding_request_url = qld_rfs.make_api_request(street_no, street, locality)
lat, long = qld_rfs.extract_lat_long(geocoding_request_url)
closest_rfs = qld_rfs.find_closest_location(lat, long, qld_rfs.QLD_RFS)
closest_rfs_formatted = f"{closest_rfs["STATION"]}, {closest_rfs["ADDRESS"]}, {closest_rfs["LOCALITY"]}"
return render_template("output.html", user_address=user_address, lat=lat, long=long,closest_rfs=closest_rfs_formatted)
@app.route('/about')
def about():
"""Handle about page"""
return render_template("about.html")
if __name__ == '__main__':
app.run()