LovnishVerma's picture
Upload 4 files
35bf195 verified
raw
history blame
1.12 kB
from flask import Flask, render_template, request
from datetime import datetime
import pytz
import joblib
app = Flask(__name__) # Inilitize the flask app
# Load the saved model
loaded_model = joblib.load('irismodel.joblib')
@app.route('/')
def index():
dt = datetime.now(pytz.timezone('Asia/Kolkata')
).strftime('%Y-%m-%d %H:%M:%S')
return render_template('index.html', dt=dt)
@app.route('/predict')
def predictpage():
return render_template('predictpage.html')
@app.route('/predictiris', methods=['POST'])
def predict():
sepal_length = float(request.form['sepal_length'])
sepal_width = float(request.form['sepal_width'])
petal_length = float(request.form['petal_length'])
petal_width = float(request.form['petal_width'])
new_data = [[sepal_length, sepal_width, petal_length, petal_width]]
prediction = loaded_model.predict(new_data)
prediction = prediction[0]
return render_template('predictpage.html', prediction=prediction)
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)