Update app.py
Browse files
app.py
CHANGED
|
@@ -8,9 +8,22 @@ result=pred[0]
|
|
| 8 |
|
| 9 |
@app.route('/')
|
| 10 |
def home():
|
| 11 |
-
|
| 12 |
-
result=pred[0]
|
| 13 |
-
return rander_template('index.html',result=result)
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# Example: expecting 4 inputs from form (Sepal length, Sepal width, Petal length, Petal width)
|
| 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 |
+
# Make prediction
|
| 23 |
+
pred = model.predict([[sl, sw, pl, pw]])
|
| 24 |
+
result = pred[0] # Predicted class (0,1,2)
|
| 25 |
+
|
| 26 |
+
return render_template('index.html', result=result)
|
| 27 |
+
|
| 28 |
+
if __name__ == '__main__':
|
| 29 |
+
app.run(debug=True, host='0.0.0.0')
|