This commit is contained in:
Ali Abid 2020-08-19 14:27:32 -07:00
commit 3ba22a9fd9

View File

@ -151,11 +151,13 @@ def serve_files_in_background(interface, port, directory_to_serve=None, server_n
if self.path == "/api/predict/":
# Make the prediction.
self._set_headers()
print("in")
data_string = self.rfile.read(
int(self.headers["Content-Length"]))
msg = json.loads(data_string)
raw_input = msg["data"]
prediction, durations = interface.process(raw_input)
print("prediction")
output = {"data": prediction, "durations": durations}
self.wfile.write(json.dumps(output).encode())
@ -262,4 +264,4 @@ def url_ok(url):
r = requests.head(url)
return r.status_code == 200
except ConnectionError:
return False
return False