-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (37 loc) · 1.37 KB
/
app.py
File metadata and controls
47 lines (37 loc) · 1.37 KB
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
from flask import Flask
from flask_restful import Resource, Api
from flask_restful import reqparse
from utils import makeprediction
app = Flask(__name__)
api = Api(app)
class Prediction(Resource):
def get(self):
parser = reqparse.RequestParser()
parser.add_argument('slength', type=float, help='slength cannot be converted')
parser.add_argument('swidth', type=float, help='swidth cannot be converted')
parser.add_argument('plength', type=float, help='plength cannot be converted')
parser.add_argument('pwidth', type=float, help='pwidth cannot be converted')
args = parser.parse_args()
print([
args['slength'],
args['swidth'],
args['plength'],
args['pwidth']
])
prediction = makeprediction.predict([
args['slength'],
args['swidth'],
args['plength'],
args['pwidth']
])
print("THE PREDICTION IS: " + str(prediction))
return {
'slength': args['slength'],
'swidth': args['swidth'],
'plength': args['plength'],
'pwidth': args['pwidth'],
'species': prediction
}
api.add_resource(Prediction, '/prediction')
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')