-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
48 lines (33 loc) · 1016 Bytes
/
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
from flask import Flask, jsonify, render_template, request
from joblib import dump, load
import numpy as np
app = Flask(__name__)
model = load('BestRF.joblib')
@app.route("/")
def home():
return render_template("index.html")
@app.route("/model")
def prediction():
return render_template("predict.html")
@app.route("/summary")
def summary():
return render_template("summary.html")
@app.route("/predict", methods=["POST"])
def predict():
# when form is submitted
if request.method == 'POST':
# convert to integers
converted = []
response = request.get_json()
print(response)
for r in response["responses"]:
r = int(r)
converted.append(r)
newconverted = np.array([converted])
result = model.predict(newconverted)
return jsonify({"result":int(result[0])})
@app.route("/visualizations")
def viz():
return render_template("visualizations.html")
if __name__ == "__main__":
app.run(debug=True)