car / app.py
Karanveer0990's picture
Update app.py
f0feb51 verified
from flask import Flask, render_template, request
import pickle
import pandas as pd
app = Flask(__name__)
# Load the model
model = pickle.load(open('Model.pkl', 'rb'))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/predict', methods=['POST'])
def predict():
if request.method == 'POST':
name = request.form['name']
company = request.form['company']
year = int(request.form['year'])
kms_driven = int(request.form['kms_driven'])
fuel_type = request.form['fuel_type']
input_df = pd.DataFrame([[name, company, year, kms_driven, fuel_type]],
columns=['name', 'company', 'year', 'kms_driven', 'fuel_type'])
prediction = model.predict(input_df)[0]
prediction = round(prediction, 2)
return render_template('index.html', prediction_text=f"Estimated Price: ₹{prediction:,}")
if __name__ == "__main__":
app.run(debug=True)