提交 f16beddd 编写于 作者: M MRXLT

fix web_service

上级 bd54ae19
...@@ -63,19 +63,25 @@ class WebService(object): ...@@ -63,19 +63,25 @@ class WebService(object):
abort(400) abort(400)
if "fetch" not in request.json: if "fetch" not in request.json:
abort(400) abort(400)
feed, fetch = self.preprocess(request.json, request.json["fetch"]) try:
if isinstance(feed, list): feed, fetch = self.preprocess(request.json,
fetch_map_batch = client_service.predict( request.json["fetch"])
feed_batch=feed, fetch=fetch) if isinstance(feed, list):
fetch_map_batch = self.postprocess( fetch_map_batch = client_service.predict(
feed=request.json, fetch=fetch, fetch_map=fetch_map_batch) feed_batch=feed, fetch=fetch)
result = {"result": fetch_map_batch} fetch_map_batch = self.postprocess(
elif isinstance(feed, dict): feed=request.json,
if "fetch" in feed: fetch=fetch,
del feed["fetch"] fetch_map=fetch_map_batch)
fetch_map = client_service.predict(feed=feed, fetch=fetch) result = {"result": fetch_map_batch}
result = self.postprocess( elif isinstance(feed, dict):
feed=request.json, fetch=fetch, fetch_map=fetch_map) 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 return result
app_instance.run(host="0.0.0.0", app_instance.run(host="0.0.0.0",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册