-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (23 loc) · 739 Bytes
/
app.py
File metadata and controls
31 lines (23 loc) · 739 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
25
26
27
28
29
30
31
import flask
from sklearn.externals import joblib
app = flask.Flask(__name__)
@app.route('/')
def test():
return 'Flask Dockerized'
@app.route("/predict", methods=["GET","POST"])
def predict():
data = {"success": False}
params = flask.request.json
if (params == None):
params = flask.request.args
# if parameters are found, echo the msg parameter
if (params != None):
text = params.get("msg")
data["message"] = text
data["personality"] = model.predict([text])[0]
data["success"] = True
# return a reponse in json format
return flask.jsonify(data)
if __name__ == '__main__':
model = joblib.load('./model/model.pkl')
app.run(debug=False,host='0.0.0.0')