1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-13 05:53:06 +01:00

timeout in testserver

This commit is contained in:
andreas
2021-10-28 09:35:20 +02:00
parent b007586076
commit edb8d6e863

View File

@@ -16,7 +16,8 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler):
apiurl=self.server.proxyUrl
url=apiurl+p.replace("/api","")
print("proxy to %s"%url)
with urllib.request.urlopen(url) as response:
try:
with urllib.request.urlopen(url,timeout=10) as response:
self.send_response(http.HTTPStatus.OK)
self.send_header("Content-type", response.getheader("Content-type"))
@@ -25,6 +26,9 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler):
return None
self.send_error(http.HTTPStatus.NOT_FOUND, "api not found")
return None
except Exception as e:
self.send_error(http.HTTPStatus.INTERNAL_SERVER_ERROR, "api error %s"%str(e))
return None
super().do_GET()
def translate_path(self, path):
"""Translate a /-separated PATH to the local filename syntax.