-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
42 lines (36 loc) · 1.25 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
from flask import Flask, render_template
from flask import request
from flask import jsonify
import numpy as np
import pickle
ml = pickle.load(open('model.pkl', 'rb'))
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/api/", methods = ['GET'])
def api():
age = request.args.get('age', type=int)
sex = request.args.get('sex', type=int)
cp = request.args.get('cp', type=int)
trtbps = request.args.get('trtbps', type=int)
chol = request.args.get('chol', type=int)
fbs = request.args.get('fbs', type=int)
restecg = request.args.get('restecg', type=int)
thalachh = request.args.get('thalachh', type=int)
exng = request.args.get('exng', type=int)
oldpeak = request.args.get('oldpeak', type=float)
slp = request.args.get('slp', type=int)
caa = request.args.get('caa', type=int)
thall = request.args.get('thall', type=int)
val = ml.predict(np.array([[age, sex, cp, trtbps, chol, fbs, restecg, thalachh, exng, oldpeak, slp, caa, thall]]))
if val in [0,1]:
return jsonify({
"result": int(val)
})
else:
return jsonify({
"result": val
})
if __name__ == '__main__':
app.run(debug=True)