diff options
| author | doobry | 2019-02-26 12:40:11 +0100 |
|---|---|---|
| committer | doobry | 2019-03-04 14:55:53 +0100 |
| commit | c52b4178403b641c4383bafc41be44ae4e669394 (patch) | |
| tree | 4d6b3bccbe909ebb45e05d4b7bd829e51424d0f8 /main.py | |
| parent | 15a1139577809b64a9f5e8048e52b643525a79a9 (diff) | |
Add support to override default templates with custom ones (Fixes: #14)
Diffstat (limited to '')
| -rw-r--r-- | main.py | 7 |
1 files changed, 7 insertions, 0 deletions
| @@ -6,6 +6,7 @@ from libmat2 import parser_factory | |||
| 6 | 6 | ||
| 7 | from flask import Flask, flash, request, redirect, url_for, render_template | 7 | from flask import Flask, flash, request, redirect, url_for, render_template |
| 8 | from flask import send_from_directory, after_this_request | 8 | from flask import send_from_directory, after_this_request |
| 9 | import jinja2 | ||
| 9 | 10 | ||
| 10 | from werkzeug.utils import secure_filename | 11 | from werkzeug.utils import secure_filename |
| 11 | 12 | ||
| @@ -14,6 +15,12 @@ app = Flask(__name__) | |||
| 14 | app.config['SECRET_KEY'] = os.urandom(32) | 15 | app.config['SECRET_KEY'] = os.urandom(32) |
| 15 | app.config['UPLOAD_FOLDER'] = './uploads/' | 16 | app.config['UPLOAD_FOLDER'] = './uploads/' |
| 16 | app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB | 17 | app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB |
| 18 | app.config['CUSTOM_TEMPLATES_DIR'] = 'custom_templates' | ||
| 19 | |||
| 20 | app.jinja_loader = jinja2.ChoiceLoader([ # type: ignore | ||
| 21 | jinja2.FileSystemLoader(app.config['CUSTOM_TEMPLATES_DIR']), | ||
| 22 | app.jinja_loader, | ||
| 23 | ]) | ||
| 17 | 24 | ||
| 18 | def __hash_file(filepath: str) -> str: | 25 | def __hash_file(filepath: str) -> str: |
| 19 | sha256 = hashlib.sha256() | 26 | sha256 = hashlib.sha256() |
