mirror of
https://0xacab.org/jvoisin/mat2-web.git
synced 2025-02-23 16:49:59 -05:00
Add support to override default templates with custom ones (Fixes: #14)
This commit is contained in:
parent
15a1139577
commit
c52b417840
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
__pycache__
|
||||
custom_templates
|
||||
|
@ -79,6 +79,12 @@ collector cronjob to remove leftover files . Besides, it can create a
|
||||
the uploads folder, to ensure that the uploaded files won't be recoverable
|
||||
between reboots.
|
||||
|
||||
# Custom templates
|
||||
|
||||
You can override the default templates from `templates/` by putting replacements
|
||||
into the directory path that's configured in `app.config['CUSTOM_TEMPLATES_DIR']`
|
||||
(default `custom_templates/`).
|
||||
|
||||
# Threat model
|
||||
|
||||
- An attacker in possession of the very same file that a user wants to clean,
|
||||
|
7
main.py
7
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user