ipl / app.py
dilpreet77's picture
Update app.py
631a1ea verified
raw
history blame contribute delete
922 Bytes
from flask import Flask, render_template, request
import joblib
import numpy as np
app = Flask(__name__)
# Load trained model
model = joblib.load("ipl_model.pkl")
@app.route('/')
def home():
return render_template("index.html")
@app.route('/predict', methods=['POST'])
def predict():
if request.method == 'POST':
try:
unnamed_col = float(request.form['unnamed'])
price_cr = float(request.form['price'])
# Prepare input
sample_input = np.array([[unnamed_col, price_cr]])
# Predict
prediction = model.predict(sample_input)[0]
return render_template("index.html",
prediction_text=f"Predicted Player/Team: {prediction}")
except Exception as e:
return render_template("index.html", prediction_text=f"Error: {e}")
if __name__ == "__main__":
app.run(debug=True)