Spaces:
Sleeping
Sleeping
| 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')) | |
| def home(): | |
| return render_template('index.html') | |
| def about(): | |
| return render_template('about.html') | |
| 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) |