From c52b4178403b641c4383bafc41be44ae4e669394 Mon Sep 17 00:00:00 2001 From: doobry Date: Tue, 26 Feb 2019 12:40:11 +0100 Subject: Add support to override default templates with custom ones (Fixes: #14) --- main.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'main.py') diff --git a/main.py b/main.py index 59c3791..033d8b6 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,7 @@ from libmat2 import parser_factory from flask import Flask, flash, request, redirect, url_for, render_template from flask import send_from_directory, after_this_request +import jinja2 from werkzeug.utils import secure_filename @@ -14,6 +15,12 @@ app = Flask(__name__) app.config['SECRET_KEY'] = os.urandom(32) app.config['UPLOAD_FOLDER'] = './uploads/' app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB +app.config['CUSTOM_TEMPLATES_DIR'] = 'custom_templates' + +app.jinja_loader = jinja2.ChoiceLoader([ # type: ignore + jinja2.FileSystemLoader(app.config['CUSTOM_TEMPLATES_DIR']), + app.jinja_loader, + ]) def __hash_file(filepath: str) -> str: sha256 = hashlib.sha256() -- cgit v1.3