-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
74 lines (72 loc) · 2.44 KB
/
main.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
from flask import Flask, render_template,request,redirect,url_for,flash
app = Flask(__name__)
import pickle
file = open('model.pkl', 'rb')
clf = pickle.load(file)
file.close()
app.secret_key='don\'t tell anyone'
@app.route('/', methods=["GET","POST"])
def main_page():
return render_template('index.html')
@app.route('/test', methods=["GET","POST"])
def test_page():
if request.method == "POST":
myDict = request.form
while True:
try:
age = int(myDict['age'])
break
except ValueError:
render_template('SAT.HTML')
sex = int(myDict['sex'])
cp = int(myDict['cp'])
while True:
try:
trestbps = int(myDict['trestbps'])
break
except ValueError:
render_template('SAT.HTML')
while True:
try:
chol = int(myDict['chol'])
break
except ValueError:
render_template('SAT.HTML')
fbs = int(myDict['fbs'])
restecg = int(myDict['restecg'])
while True:
try:
thalach = int(myDict['thalach'])
break
except ValueError:
render_template('SAT.HTML')
exang = int(myDict['exang'])
while True:
try:
oldpeak = int(myDict['oldpeak'])
break
except ValueError:
render_template('SAT.HTML')
slope = int(myDict['slope'])
while True:
try:
ca = int(myDict['ca'])
break
except ValueError:
render_template('SAT.HTML')
thal=int(myDict['thal'])
inputFeatures = [age,sex,cp,trestbps,chol, fbs,restecg,thalach,exang,oldpeak,slope,ca,thal]
infProb = clf.predict([inputFeatures])
print(infProb)
if infProb==[1]:
s = "You may have problem in your heart! Please go through the links below!"
return render_template('result.html',inf=s)
elif infProb==[0]:
s = "Cogratulations! You don't have any heart problem...\nBut if you feal seek than check out the links below!"
return render_template('result.html', inf=s)
return render_template('SAT.html')
@app.route('/about', methods=["GET","POST"])
def about_page():
return render_template('about.html')
if __name__ == "__main__":
app.run(debug = True)