fixed stuff included a fully working downloader for webpages which inlines the css / js. images do not work because they are hosted on the server

This commit is contained in:
2025-09-30 19:01:59 +02:00
parent 1f46207a64
commit f50d8f9d69
4 changed files with 64 additions and 20 deletions

View File

@@ -139,8 +139,8 @@ class MyHandler(BaseHTTPRequestHandler):
logger.log_info(f"Served markdown file: {markdown_filename}")
return
except Exception as e:
logger.log_error(f"Error serving markdown file {markdown_filename}: {e}")
except Exception as err:
logger.log_error(f"Error serving markdown file {markdown_filename}: {err}")
self.send_response(500)
self.end_headers()
self.wfile.write(b"500 - Internal Server Error")
@@ -166,8 +166,8 @@ class MyHandler(BaseHTTPRequestHandler):
if mime_type == "application/javascript" or file_path.endswith(".js"):
try:
content = jsmin(content.decode("utf-8")).encode("utf-8")
except Exception as e:
logger.log_error(f"Error minifying JS file {file_path}: {e}")
except Exception as err:
logger.log_error(f"Error minifying JS file {file_path}: {err}")
self.send_response(200)
self.send_header("Content-type", mime_type)
@@ -190,7 +190,7 @@ if __name__ == "__main__":
logger.log_debug("Started PyPost.py in background watcher thread.")
server_address = ("localhost", 8000)
httpd = HTTPServer(server_address, MyHandler)
httpd: HTTPServer = HTTPServer(server_address, MyHandler) # type: ignore[arg-type]
logger.log_info(f"Serving on http://{server_address[0]}:{server_address[1]}")
httpd.serve_forever()
except (Exception, KeyboardInterrupt) as e: