from plomtask.misc import HandledException
from plomtask.db import DatabaseConnection
+TEMPLATES_DIR = 'templates'
+
class TaskServer(HTTPServer):
"""Variant of HTTPServer that knows .jinja as Jinja Environment."""
- def __init__(self, templates_dir, db_file, *args, **kwargs):
+ def __init__(self, db_file, *args, **kwargs):
super().__init__(*args, **kwargs)
self.db = db_file
- self.jinja = JinjaEnv(loader=JinjaFSLoader(templates_dir))
+ self.jinja = JinjaEnv(loader=JinjaFSLoader(TEMPLATES_DIR))
class TaskHandler(BaseHTTPRequestHandler):
PLOMTASK_DB_PATH = environ.get('PLOMTASK_DB_PATH')
HTTP_PORT = 8082
-TEMPLATES_DIR = 'templates'
DB_CREATION_ASK = 'Database file not found. Create? Y/n\n'
else:
print('Not recognizing reply as "yes".')
raise HandledException('Cannot run without database.')
- server = TaskServer(TEMPLATES_DIR, db_file,
- ('localhost', HTTP_PORT), TaskHandler)
+ server = TaskServer(db_file, ('localhost', HTTP_PORT), TaskHandler)
print(f'running at port {HTTP_PORT}')
try:
server.serve_forever()