-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
58 lines (45 loc) · 1.54 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
This script runs the application using a development server.
It contains the definition of routes and views for the application.
"""
from flask import Flask,request,jsonify
import json
app = Flask(__name__)
# Make the WSGI interface available at the top level so wfastcgi can get it.
wsgi_app = app.wsgi_app
@app.route('/')
def hello():
"""Renders a sample page."""
return "Hello World!"
@app.route('/predict' , methods=['POST'])
def predict():
data=request.stream.read()
return json.dumps(data.decode("utf-8"))
#return json.dumps({'prediction': data})
#X = np.empty((0,20,9))
#dizi=request.args.get('dnm');
#dizi=dizi.replace(" ",",")
#dizi=dizi.replace("[,","[")
#dnm=ast.literal_eval(dizi);
#dnm=list(dnm)
#npdizi=np.array(dnm)
##npdizi=pd.DataFrame(npdizi)
#X = np.append(X, [npdizi], axis=0)
#for i in range(X.shape[1]):
# X[:, i, :] = scalers[i].transform(X[:, i, :])
#n_timesteps, n_features = X.shape[1], X.shape[2]
#n_steps, n_length = 2, 10
#X = X.reshape((X.shape[0], n_steps, n_length, n_features))
#result=model.predict_classes(X).tolist()
#return json.dumps({'prediction': result})
##return jsonify({'prediction': result.tolist()})
##return str(npdizi)
##return str(result)
if __name__ == '__main__':
import os
HOST = os.environ.get('SERVER_HOST', 'localhost')
try:
PORT = int(os.environ.get('SERVER_PORT', '5555'))
except ValueError:
PORT = 5555
app.run(HOST, PORT)