From bc1b3029517d9a54e91433348671e97784aeada6 Mon Sep 17 00:00:00 2001 From: MRXLT Date: Wed, 1 Apr 2020 04:33:42 +0000 Subject: [PATCH] fix web_service --- python/paddle_serving_server/web_service.py | 32 ++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/python/paddle_serving_server/web_service.py b/python/paddle_serving_server/web_service.py index 098b3c51..e94916cc 100755 --- a/python/paddle_serving_server/web_service.py +++ b/python/paddle_serving_server/web_service.py @@ -63,19 +63,25 @@ class WebService(object): abort(400) if "fetch" not in request.json: abort(400) - feed, fetch = self.preprocess(request.json, request.json["fetch"]) - if isinstance(feed, list): - fetch_map_batch = client_service.predict( - feed_batch=feed, fetch=fetch) - fetch_map_batch = self.postprocess( - feed=request.json, fetch=fetch, fetch_map=fetch_map_batch) - result = {"result": fetch_map_batch} - elif isinstance(feed, dict): - if "fetch" in feed: - del feed["fetch"] - fetch_map = client_service.predict(feed=feed, fetch=fetch) - result = self.postprocess( - feed=request.json, fetch=fetch, fetch_map=fetch_map) + try: + feed, fetch = self.preprocess(request.json, + request.json["fetch"]) + if isinstance(feed, list): + fetch_map_batch = client_service.predict( + feed_batch=feed, fetch=fetch) + fetch_map_batch = self.postprocess( + feed=request.json, + fetch=fetch, + fetch_map=fetch_map_batch) + result = {"result": fetch_map_batch} + elif isinstance(feed, dict): + if "fetch" in feed: + del feed["fetch"] + fetch_map = client_service.predict(feed=feed, fetch=fetch) + result = self.postprocess( + feed=request.json, fetch=fetch, fetch_map=fetch_map) + except ValueError: + result = {"result": "Request Value Error"} return result app_instance.run(host="0.0.0.0", -- GitLab