-Open Rail Data Disclaimer Etc. | No Guarantees or Whatever | We do freelance and dont want to be poor.
-
-
-
-
-"""
+DEFAULT_TEMPLATE_PATH = Path(__file__).parents[2] / "media/template.html"
logger: Logger = Logger(name=__name__, level=INFO)
@@ -87,7 +49,7 @@ class FaresHandler(BaseHTTPRequestHandler):
text = text[1]
return {s.split("=")[0]: s.split("=")[-1] for s in text.split("&")}
- def content_of_GET(self) -> str:
+ def content_of_GET(self, template_path: Path = DEFAULT_TEMPLATE_PATH) -> str:
"""
Generates the content of a GET request.
Responsible for receiving the requests' details and constructing the output.
@@ -122,7 +84,8 @@ class FaresHandler(BaseHTTPRequestHandler):
text += fares_table.to_html()
text += " \n "
text += ""
- return HTML_CONTENT_HEADER + text + HTML_CONTENT_FOOTER
+ with open(template_path, "r") as rf:
+ return rf.read().replace("", text)
def do_GET(self) -> None:
"""