(self)
| 26 | class PredictionHandler(tornado.web.RequestHandler): |
| 27 | # predict one sample at a time |
| 28 | def post(self): |
| 29 | # print "body:", self.request.body |
| 30 | # print "arguments:", self.request.arguments |
| 31 | # will look like this: |
| 32 | # body: three=four&one=two |
| 33 | # arguments: {'three': ['four'], 'one': ['two']} |
| 34 | params = self.request.arguments |
| 35 | x = np.array(list(map(float, params['input']))) |
| 36 | y = model.predict([x])[0] |
| 37 | self.write(json.dumps({'prediction': y.item()})) |
| 38 | self.finish() |
| 39 | |
| 40 | if __name__ == "__main__": |
| 41 | application = tornado.web.Application([ |
no test coverage detected