-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
42 lines (29 loc) · 964 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
from flask import Flask, render_template, request
import numpy as np
import joblib
print("Starting Flask app...")
app = Flask(__name__, template_folder='templates')
model = joblib.load('model.pkl')
print(type(model))
@app.route('/')
def welcome():
return render_template("welcome.html")
@app.route('/dep_test', methods=['POST','GET'])
def dep_test():
if request.method == 'POST':
values = [int(x) for x in request.form.values()]
final = np.array(values).reshape(1,-1)
int_predict = model.predict(final)
if int_predict == 0:
int_predict = "High"
elif int_predict == 1:
int_predict = "Low"
elif int_predict == 2:
int_predict = "Mild"
else:
int_predict = "Moderate"
return render_template("result.html", results=int_predict)
else:
return render_template('dep_test.html')
if __name__ == "__main__":
app.run(debug=True)