Rohit001 commited on
Commit
699c926
1 Parent(s): 6d845f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -21
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from flask import Flask,request,render_template
2
  import pickle
3
  import numpy as np
4
 
@@ -8,26 +8,30 @@ app = Flask(__name__)
8
  load = pickle.load(open('./model.sav','rb'))
9
 
10
 
11
- @app.route('/',methods=['POST','GET'])
12
  def home():
13
- if request.method == 'POST':
14
- preg = request.form.get("preg")
15
- bmi = request.form.get("bmi")
16
- bp = request.form.get("bp")
17
- skin = request.form.get("skin")
18
- dp = request.form.get("dp")
19
- gl = request.form.get("gl")
20
- il = request.form.get("il")
21
- age = request.form.get("age")
22
- features = np.array([[preg,gl,bp,skin,il,bmi,dp,age]])
23
- pred = load.predict(features)
24
- if pred == 1 :
25
- output = "Yes, you have Diabaties."
26
- elif pred == 0:
27
- output = "No, you do not have Diabaties."
28
- else :
29
- output = pred
30
- return render_template('index.html',res=output)
31
  return render_template('index.html')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  if __name__ == "__main__":
33
- app.run(debug=False)
 
1
+ from flask import Flask,request,render_template,redirect
2
  import pickle
3
  import numpy as np
4
 
 
8
  load = pickle.load(open('./model.sav','rb'))
9
 
10
 
11
+ @app.route('/')
12
  def home():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  return render_template('index.html')
14
+
15
+ @app.route('/predict',methods=['POST'])
16
+ def predict():
17
+
18
+ preg = request.form.get("preg")
19
+ bmi = request.form.get("bmi")
20
+ bp = request.form.get("bp")
21
+ skin = request.form.get("skin")
22
+ dp = request.form.get("dp")
23
+ gl = request.form.get("gl")
24
+ il = request.form.get("il")
25
+ age = request.form.get("age")
26
+ features = np.array([[preg,gl,bp,skin,il,bmi,dp,age]])
27
+ pred = load.predict(features)
28
+ if pred == 1 :
29
+ output = "Yes, you have Diabaties."
30
+ elif pred == 0:
31
+ output = "No, you do not have Diabaties."
32
+ else :
33
+ output = pred
34
+ return render_template('index.html',res=output)
35
+
36
  if __name__ == "__main__":
37
+ app.run(host="0.0.0.0", port=7860)