-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
42 lines (34 loc) · 1.64 KB
/
app.py
File metadata and controls
42 lines (34 loc) · 1.64 KB
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
37
38
39
40
41
42
from flask import Flask, render_template, request
from stations import getStations, Car, getStationsDistance, getMonthlyPriceTransportation, getDailyPrice, getStation, getCar
application = Flask(__name__)
array = []
stations_array=getStations()
@application.route("/")
def landing():
avg_saved_per_month = 52
return render_template('index.html', avg_saved=avg_saved_per_month)
@application.route("/personalised", methods=['GET', 'POST'])
def personalised():
if len(array) == 0:
for station in stations_array:
array.append(station.name)
if request.method == 'GET':
return render_template('personalised.html', post=False, stations=array, alert_user=False)
else:
print(request.form['dropdowncars'])
car = getCar(request.form['dropdowncars'])
print(type(car))
fromStation = getStation(request.form['from'])
toStation = getStation(request.form['to'])
distance = getStationsDistance(fromStation, toStation)
incorrect_stations = False
if fromStation.name == "" or toStation.name == "":
incorrect_stations = True
return render_template('personalised.html',
car_monthly=(car.getMonthlyPriceGas(distance)+car.getMonthlyLossofValue(distance)),
car_daily=(car.getDailyPriceGas(distance)+car.getDailyLossofValue(distance)),
public_transport_monthly=getMonthlyPriceTransportation(fromStation, toStation),
public_transport_daily=getDailyPrice(fromStation, toStation),
post=True, stations=array, alert_user=incorrect_stations)
if __name__ == "__main__":
application.run(host='127.0.0.1')