From ada28eb7aed2b69947d5908ead959d36da4df79e Mon Sep 17 00:00:00 2001 From: Dobin Date: Fri, 26 Aug 2022 17:05:33 +0200 Subject: [PATCH] ui: file log display --- app/__init__.py | 4 + app/templates/file.html | 1133 +-------------------------- app/templates/file_log.html | 1 + app/templates/file_matches_css.html | 1124 ++++++++++++++++++++++++++ app/templates/file_verifier.html | 2 - app/views.py | 16 +- 6 files changed, 1151 insertions(+), 1129 deletions(-) create mode 100644 app/templates/file_log.html create mode 100644 app/templates/file_matches_css.html diff --git a/app/__init__.py b/app/__init__.py index 97b9342..8a05cb7 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,3 +1,4 @@ +import os from flask import Flask UPLOAD_FOLDER = './app/upload' @@ -7,4 +8,7 @@ app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER app.jinja_env.auto_reload = True app.config["TEMPLATES_AUTO_RELOAD"] = True +app.config['SECRET_KEY'] = os.urandom(24) +app.config['SESSION_TYPE'] = 'filesystem' + from app import views diff --git a/app/templates/file.html b/app/templates/file.html index 5408fc0..0c10447 100644 --- a/app/templates/file.html +++ b/app/templates/file.html @@ -17,11 +17,13 @@ +
+ {% include 'file_matches.html' %}
@@ -29,1131 +31,14 @@ {% include 'file_verifier.html' %} {% endif %}
-
...
+
+ {% if logData != None %} + {% include 'file_log.html' %} + {% endif %} +
- - diff --git a/app/templates/file_log.html b/app/templates/file_log.html new file mode 100644 index 0000000..0c99f2a --- /dev/null +++ b/app/templates/file_log.html @@ -0,0 +1 @@ +
{{ logData }}
\ No newline at end of file diff --git a/app/templates/file_matches_css.html b/app/templates/file_matches_css.html new file mode 100644 index 0000000..c4a11de --- /dev/null +++ b/app/templates/file_matches_css.html @@ -0,0 +1,1124 @@ + + + \ No newline at end of file diff --git a/app/templates/file_verifier.html b/app/templates/file_verifier.html index e46024e..d544fc3 100644 --- a/app/templates/file_verifier.html +++ b/app/templates/file_verifier.html @@ -28,6 +28,4 @@ {% endfor %} - - diff --git a/app/views.py b/app/views.py index ee9c883..6733b81 100644 --- a/app/views.py +++ b/app/views.py @@ -31,7 +31,7 @@ def example(path): @app.route("/view_file/") def view_file(filename): filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename + EXT_INFO) - filepathLog = os.path.join(app.config['UPLOAD_FOLDER'],filename + EXT_LOG) + filepathLog = os.path.join(app.config['UPLOAD_FOLDER'], filename + EXT_LOG) logData = "" if os.path.isfile(filepathLog): with open(filepathLog) as f: @@ -68,15 +68,25 @@ def file(filename): with open(filename, 'rb') as f: fileContent = f.read() + # log file + filepathLog = filename + EXT_LOG + logData = "" + if os.path.isfile(filepathLog): + with open(filepathLog) as f: + logData = f.read() + # VerifyData verifyDataFile = filename + EXT_INFO fileData: FileData = None if os.path.isfile(verifyDataFile): with open(verifyDataFile, "rb") as input_file: fileData = pickle.load(input_file) - + return render_template('file.html', - filename=filename, matches=fileData.matches, verifications=fileData.verifications) + filename=filename, + matches=fileData.matches, + verifications=fileData.verifications, + logData=logData) def allowed_file(filename):