X-Git-Url: https://plomlompom.com/repos/unset_cookie?a=blobdiff_plain;f=task.py;h=d6128eeed5fc20d0d919a91dc3c00fea14ad4150;hb=ee89735cb3714dc7c3ec8bbd0643cf279ee9a1ef;hp=a1510b0a202571796a5da96262fc115fb3e85a84;hpb=5744cbdb67c253d8a8d54eb9710958a66a64fbb6;p=plomtask diff --git a/task.py b/task.py index a1510b0..d6128ee 100755 --- a/task.py +++ b/task.py @@ -4,8 +4,11 @@ plom's task manager """ from http.server import BaseHTTPRequestHandler from http.server import HTTPServer +from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader +from days import Day HTTP_PORT = 8082 +TEMPLATES_DIR = 'templates' class HandledException(Exception): @@ -19,13 +22,17 @@ class TaskHandler(BaseHTTPRequestHandler): """Handle any GET request.""" self.send_response(200) self.end_headers() - html = '
hi there!
' + days = [Day('2024-01-03'), Day('2024-01-01'), Day('2024-01-02')] + days.sort() + html = self.server.jinja.get_template('calendar.html').render( + days=days) self.wfile.write(bytes(html, 'utf-8')) def main(): """Main loop.""" server = HTTPServer(('localhost', HTTP_PORT), TaskHandler) + server.jinja = JinjaEnv(loader=JinjaFSLoader(TEMPLATES_DIR)) print(f'running at port {HTTP_PORT}') try: server.serve_forever()