Jobanjps commited on
Commit
40c4df3
·
verified ·
1 Parent(s): 9b86406

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 (3).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")