-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
124 lines (105 loc) · 3.86 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from combine_pm_gps import combine_pm_gps_csvs
import re
import plotly
import plotly.express as px
from flask import Flask, render_template, request
from datetime import datetime
# import other python files & functions
import plot_pm_data
import process_pm_data
import combine_pm_gps
from pm_stats_to_display import *
from weather_api import *
import geo_plotting
app = Flask(__name__)
@app.route("/")
def home():
# clean up the airquality data
process_pm_data.main()
#run & combine new data
combine_pm_gps.combine_pm_gps_csvs()
pm1_to_display = get_pm1_last10_avg()
pm10_to_display = get_pm10_last10_avg()
pm25_to_display = get_pm25_last10_avg()
zipCode = 91711
weather = get_weather_json(zipCode)
weather_time = weather[0]
weather_description = weather[2]
temperature_to_send = weather[3]
feels_like = weather[4]
humidity_to_send = weather[5]
wind_speed = weather[6]
return render_template('index.html',
pm1LastTenAvg = pm1_to_display,
pm10LastTenAvg = pm10_to_display,
pm25LastTenAvg = pm25_to_display,
weatherTime = weather_time,
temperature = temperature_to_send,
feelsLike = feels_like,
humidity = humidity_to_send,
description = weather_description,
windSpeed = wind_speed
)
@app.route("/pm1")
def pm1():
pm_size = 'pm1'
most_recent_pm = most_recent_pm_reading(pm_size)
last_hour = pm_last_hr_avg(pm_size)
last_day = pm_last_day_avg(pm_size)
last_week = pm_last_week_avg(pm_size)
all_time = pm_all_time_avg(pm_size)
return render_template('pm1.html',
mostRecent = most_recent_pm,
lastHour=last_hour, lastDay=last_day,
lastWeek=last_week, allTime= all_time)
@app.route("/pm1-map.html")
def pm1_map():
geo_plotting.plot_pm_and_gps("pm1")
return render_template('pm1-map.html')
@app.route("/pm25")
def pm25():
pm_size = 'pm25'
most_recent_pm = most_recent_pm_reading(pm_size)
last_hour = pm_last_hr_avg(pm_size)
last_day = pm_last_day_avg(pm_size)
last_week = pm_last_week_avg(pm_size)
all_time = pm_all_time_avg(pm_size)
return render_template('pm25.html',
mostRecent = most_recent_pm,
lastHour=last_hour, lastDay=last_day,
lastWeek=last_week, allTime= all_time)
@app.route("/pm25-map.html")
def pm25_map():
geo_plotting.plot_pm_and_gps("pm25")
return render_template('pm25-map.html')
@app.route("/pm10")
def pm10():
pm_size = 'pm10'
most_recent_pm = most_recent_pm_reading(pm_size)
last_hour = pm_last_hr_avg(pm_size)
last_day = pm_last_day_avg(pm_size)
last_week = pm_last_week_avg(pm_size)
all_time = pm_all_time_avg(pm_size)
return render_template('pm10.html',
mostRecent = most_recent_pm,
lastHour=last_hour, lastDay=last_day,
lastWeek=last_week, allTime= all_time)
@app.route("/pm10-map.html")
def pm10_map():
geo_plotting.plot_pm_and_gps("pm10")
return render_template('pm10-map.html')
@app.route("/plot_all_pm.html")
def plot_all_pm():
return render_template('/plot_all_pm.html',
graphJSON = plot_pm_data.plot_all_pm_timeseries())
@app.route("/what_is_pm")
def what_is_pm():
return render_template('/what_is_pm.html')
@app.route("/env_justice")
def env_justice():
return render_template('/env_justice.html')
@app.route("/future_applications")
def future_applications():
return render_template('/future_applications.html')
if __name__ == "__main__":
app.run(debug=True)