-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
65 lines (49 loc) · 1.84 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
from flask import Flask, Markup, render_template, jsonify
import pandas as pd
import sqlite3
import queries
app = Flask(__name__)
conn = sqlite3.connect("ETL-backend/sentencing.db", check_same_thread=False)
@app.route("/")
def index():
return render_template('index.html', item='index')
@app.route('/demographics')
def demographics():
return render_template('demographics.html', item='demographics')
@app.route("/demographics/data")
def demographics_data():
demographics = pd.read_sql_query(queries.demographics, con=conn)
return demographics.to_json(orient='records')
@app.route('/offense_category')
def offense_category():
return render_template('offense_category.html', item='offense_category')
@app.route('/offense_category/box')
def oc_box():
age_box_df = pd.read_sql_query(queries.age_box, con=conn)
return age_box_df.to_json(orient='records')
@app.route('/length_of_case')
def length_of_case():
return render_template('length_of_case.html', item='length_of_case')
@app.route("/length_of_case/scatter")
def length_scatter():
length_scatter_df = pd.read_sql_query(queries.length_scatter, con=conn)
return length_scatter_df.to_json(orient='records')
@app.route("/length_of_case/box")
def length_box():
length_box_df = pd.read_sql_query(queries.offense_box, con=conn)
return length_box_df.to_json(orient='records')
@app.route('/courts')
def courts():
return render_template('courts.html', item='courts')
@app.route("/courts/data")
def courts_data():
courts_df = pd.read_sql_query(queries.courts_data, con=conn)
return courts_df.to_json(orient='records')
@app.route('/about')
def about():
return render_template('about.html', item='about')
@app.route('/map')
def map():
return render_template('map-v2.html', text= "Judicial Districts Map", item='map')
if __name__ == "__main__":
app.run(debug=True)