-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
79 lines (56 loc) · 2.06 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
#######################################################
################ Flask Application #################
################## Dependencies ###################
####################################################
import os
import pandas as pd
import numpy as np
import json
from flask import Flask, jsonify, render_template
app = Flask(__name__)
#######################################################
################### App Routes #####################
#####################################################
@app.route("/")
def index():
print("Return the homepage")
return render_template("explore.html")
# This route displays the main dashboard users may interact with
@app.route("/explore/")
def dashboard():
print()
return render_template("explore.html")
# Route for geoJSON data
@app.route('/jsonifiedGeo/')
def geoJSONIFIED():
print("Preparing geoJSON for mapping")
f = open('static/data/EPIC_data_1405.geojson', 'r')
return f.read()
# This route reads in CSVs containing datapoints and converts them to JSON format
# for easy manipulation with D3 within JS files
@app.route("/jsonifiedData/")
def jsonified():
print("Formatting CSVs to JSON")
# Funtion for reading CSV in as DataFrame
def csvDF(oldCSVfilepath):
csvIN = pd.read_csv(oldCSVfilepath)
DF = pd.DataFrame(csvIN)
return DF
# Zillow and commute data
zillCommDF = csvDF("./static/data/zillowCommuteData.csv")
jsonZillComm = json.loads(zillCommDF.to_json(orient='records'))
# Crime data
crimeDF = csvDF("./static/data/crimeData.csv")
jsonCrime = json.loads(crimeDF.to_json(orient='records'))
# School data
schoolDF = csvDF("./static/data/schoolDataFINAL.csv")
jsonSchool = json.loads(schoolDF.to_json(orient='records'))
return jsonify(jsonZillComm, jsonCrime, jsonSchool)
# This route displays dynamic timelapse map of Austin properties
# as well as general trends observed
@app.route("/trends")
def trends():
print()
return render_template("trends.html")
if __name__ == "__main__":
app.run(debug=True)