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

Merge branch 'master' into boards

This commit is contained in:
free-x
2021-10-29 07:33:09 +02:00
committed by GitHub
20 changed files with 629 additions and 388 deletions

View File

@@ -16,15 +16,19 @@ 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:
self.send_response(http.HTTPStatus.OK)
self.send_header("Content-type", response.getheader("Content-type"))
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"))
self.end_headers()
shutil.copyfileobj(response,self.wfile)
self.end_headers()
shutil.copyfileobj(response,self.wfile)
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
self.send_error(http.HTTPStatus.NOT_FOUND, "api not found")
return None
super().do_GET()
def translate_path(self, path):
"""Translate a /-separated PATH to the local filename syntax.