flaskstart / app.py
Mrvishal999's picture
Update app.py
cc7004d verified
raw
history blame contribute delete
763 Bytes
from flask import Flask, render_template, request
import pickle
import os
app = Flask(__name__)
# Get the path to the pickled model file from environment variables
file_path = 'myhpp1.pickle'
with open(file_path, 'rb') as f:
loadmodel = pickle.load(f)
@app.route("/")
def form():
try:
return render_template("forms.html")
except Exception as e:
return str(e)
@app.route("/result", methods=["POST"])
def result():
try:
sqft = float(request.form.get("sqft"))
bhk = int(request.form.get("bath"))
pp = (loadmodel.predict([[sqft, bhk]])[0][0]).round(2)
return render_template("result.html", pp=pp)
except Exception as e:
return str(e)
if __name__ == "__main__":
app.run(debug=True)