-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (23 loc) · 773 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
34
35
from flask import Flask, render_template, request
import joblib
from pathlib import Path
app = Flask(__name__)
# https://stackoverflow.com/a/75262400/3693763
# https://stackoverflow.com/a/69635854/3693763
app.config.update(TEMPLATES_AUTO_RELOAD=True)
path = Path(__file__).parent
file_name = "/model.pkl"
model = joblib.load(
open(f"{path}{file_name}", "rb")
)
@app.route("/")
def index_page():
return render_template("index.html")
@app.route("/predict", methods=["POST"])
def predict_music_genre():
age = int(request.form["age"])
gender = int(request.form["gender"])
prediction = model.predict([[age, gender]])
return render_template("index.html", age=age, gender=gender, prediction=prediction)
if __name__ == "__main__":
app.run()