-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
33 lines (21 loc) · 873 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Flask, request, render_template
from utils import convert_to_dict, load_model, query_processing
MODEL_FOLDER_PATH = "./models/"
MODEL_NAME = "st.pkl"
app = Flask(__name__, template_folder="templates")
@app.route("/", methods=["GET", "POST"])
def index():
if request.method == "POST":
keys = list(request.form.keys())
values = list(request.form.values())
query = convert_to_dict(keys, values)
processed_query = query_processing(query)
model = load_model(MODEL_FOLDER_PATH, MODEL_NAME)
prediction = model.predict(processed_query)[0]
return render_template(
"index.html", prediction=f"The Car Mileage is : {prediction : .2f} MPG"
)
else:
return render_template("index.html", prediction="Click Above to predict")
if __name__ == "__main__":
app.run()