-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
31 lines (22 loc) · 883 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
import numpy as np
from flask import Flask, render_template, request, url_for
import pickle
import os
app = Flask('__name__', template_folder='template',static_folder='static')
model = pickle.load(open('model.pkl', 'rb'))
port=int(os.environ.get('PORT',5000))
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=["GET","POST"])
def predict():
init_features = [float(x) for x in request.form.values()]
final_features = [np.array(init_features)]
prediction = model.predict(final_features)
if prediction == 1:
result = 'YAY! User will buy the insurance.'
else:
result = 'OOPS! User wont buy the insurance.'
return render_template('index.html', prediction_text='Prediction: {}'.format(result))
if __name__ == '__main__':
app.run(host='0.0.0.0',port=port)