Rahul23232 commited on
Commit
b733494
·
verified ·
1 Parent(s): c9ba350

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
+ from sklearn.linear_model import LogisticRegression
3
+ import joblib
4
+
5
+ app = Flask(__name__)
6
+
7
+ # Load model
8
+ model = joblib.load('iris_model1.joblib')
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
+ sl = float(request.form['sepal_length'])
18
+ sw = float(request.form['sepal_width'])
19
+ pl = float(request.form['petal_length'])
20
+ pw = float(request.form['petal_width'])
21
+
22
+ # Predict species
23
+ input_data = [[sl, sw, pl, pw]]
24
+ pred = model.predict(input_data)
25
+
26
+ return render_template('index.html', data=pred[0])
27
+
28
+ if __name__ == '__main__':
29
+ app.run(debug=True)