Prashant43 commited on
Commit
f439552
·
verified ·
1 Parent(s): 1c2a0b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -7
app.py CHANGED
@@ -1,13 +1,29 @@
1
  from flask import Flask, render_template, request
2
  import joblib
3
 
4
- app= Flask(__name__)
5
 
 
6
  model = joblib.load('iris_model.pkl')
7
- pred = model.predict([5.1,3.5,1.4,0.2])
8
- result = pred[0]
9
  @app.route("/")
10
- def home()
11
- return result
12
- if __name__ = "__main__":
13
- app.run(debug=True,host="0.0.0.0")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from flask import Flask, render_template, request
2
  import joblib
3
 
4
+ app = Flask(__name__)
5
 
6
+ # Load the trained model
7
  model = joblib.load('iris_model.pkl')
8
+
 
9
  @app.route("/")
10
+ def home():
11
+ return render_template("index.html")
12
+
13
+ @app.route("/predict", methods=['POST'])
14
+ def predict():
15
+ if request.method == 'POST':
16
+ # Get values from form
17
+ sl = float(request.form['sl'])
18
+ sw = float(request.form['sw'])
19
+ pl = float(request.form['pl'])
20
+ pw = float(request.form['pw'])
21
+
22
+ # Make prediction
23
+ pred = model.predict([[sl, sw, pl, pw]])
24
+ result = pred[0]
25
+
26
+ return render_template("index.html", data=result)
27
+
28
+ if __name__ == '__main__':
29
+ app.run(debug=True, host="0.0.0.0")