from plomtask.days import Day
from plomtask.misc import HandledException
-TEMPLATES_DIR = 'templates'
-
class TaskServer(HTTPServer):
"""Variant of HTTPServer that knows .jinja as Jinja Environment."""
- def __init__(self, *args, **kwargs):
- x = super().__init__(*args, **kwargs)
- self.jinja = JinjaEnv(loader=JinjaFSLoader(TEMPLATES_DIR))
+ def __init__(self, templates_dir, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.jinja = JinjaEnv(loader=JinjaFSLoader(templates_dir))
class TaskHandler(BaseHTTPRequestHandler):
from plomtask.http import TaskHandler, TaskServer
HTTP_PORT = 8082
+TEMPLATES_DIR = 'templates'
if __name__ == '__main__':
try:
- server = TaskServer(('localhost', HTTP_PORT), TaskHandler)
+ server = TaskServer(TEMPLATES_DIR,
+ ('localhost', HTTP_PORT), TaskHandler)
print(f'running at port {HTTP_PORT}')
try:
server.serve_forever()