Rahul23232's picture
Create app.py
b733494 verified
raw
history blame contribute delete
688 Bytes
from flask import Flask, render_template, request
from sklearn.linear_model import LogisticRegression
import joblib
app = Flask(__name__)
# Load model
model = joblib.load('iris_model1.joblib')
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
sl = float(request.form['sepal_length'])
sw = float(request.form['sepal_width'])
pl = float(request.form['petal_length'])
pw = float(request.form['petal_width'])
# Predict species
input_data = [[sl, sw, pl, pw]]
pred = model.predict(input_data)
return render_template('index.html', data=pred[0])
if __name__ == '__main__':
app.run(debug=True)