-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
25 lines (19 loc) · 797 Bytes
/
Copy pathserver.py
File metadata and controls
25 lines (19 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np
from flask import Flask, request, jsonify
import pickle
app = Flask(__name__)
model = pickle.load(open('model.pkl', 'rb'))
@app.route('/api/', methods = ['POST'])
def predict():
data = request.get_json(force = True)
prediction = model.predict([[np.array(data['fa'], data['va'], data['ca'], data['rs'],
data['chlorides'], data['fsd'], data['tsd'],
data['density'], data['ph'], data['sulphates'],
data['alcohol'])]])
output = prediction[0]
return jsonify(output)
if __name__ == '__main__':
try:
app.run(port=5000, debug = True)
except:
print("Server is exited unexpectedly. Please contact server admin.")