#!/usr/bin/env python3
-"""
-plom's task manager
-"""
+"""plom's task manager"""
from http.server import BaseHTTPRequestHandler
from http.server import HTTPServer
+from urllib.parse import urlparse
+from os.path import split as path_split
from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFSLoader
from days import Day
def do_GET(self):
"""Handle any GET request."""
+ parsed_url = urlparse(self.path)
+ site = path_split(parsed_url.path)[1]
+ if 'calendar' == site:
+ html = self.do_GET_calendar()
+ else:
+ html = self.do_GET_msg('I have nothing to say at this point.')
self.send_response(200)
self.end_headers()
+ self.wfile.write(bytes(html, 'utf-8'))
+
+ def do_GET_msg(self, msg):
+ """Show message."""
+ return self.server.jinja.get_template('msg.html').render(
+ msg=msg)
+
+ def do_GET_calendar(self):
+ """Show sorted Days."""
days = [Day('2024-01-03'), Day('2024-01-01'), Day('2024-01-02')]
days.sort()
- html = self.server.jinja.get_template('calendar.html').render(
+ return self.server.jinja.get_template('calendar.html').render(
days=days)
- self.wfile.write(bytes(html, 'utf-8'))
def main():