webfront.py

changeset 100
62759e5c4554
parent 99
01941a811b5a
child 112
d997456985b2
--- a/webfront.py	Tue Aug 25 22:10:04 2020 +0300
+++ b/webfront.py	Tue Aug 25 22:20:15 2020 +0300
@@ -1,10 +1,11 @@
 #!/usr/bin/env python3
 from flask import Flask, render_template, redirect, request
+from ldcheck import appname, version, version_string
 from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths
 from parse import read_ldraw
 from testsuite import load_tests, check_model, problem_text, all_problem_types
 
-app = Flask('LDCheck')
+app = Flask(appname)
 
 def format_report_html(report, model, test_suite):
     messages = []
@@ -25,6 +26,11 @@
 @app.route('/', methods = ['GET', 'POST'])
 def web_front():
     test_suite = load_tests()
+    common_args = {
+        'appname': appname,
+        'version': version_string,
+        'is_debug': max(version) == 9999,
+    }
     if request.method == 'POST':
         # check if the post request has the file part
         if 'file' not in request.files or not request.files['file'].filename:
@@ -39,6 +45,7 @@
             file.stream,
             name = filename,
             ldraw_directories = config['libraries'],
+            **common_args,
         )
         report = check_model(model, test_suite)
 
@@ -50,14 +57,16 @@
         return render_template('webfront.html',
             report = report,
             name = filename,
-            problem_types = all_problem_types(test_suite)
+            problem_types = all_problem_types(test_suite),
+            **common_args,
         )
     else:
         test_suite = load_tests()
         return render_template('webfront.html',
             report = None,
             name = None,
-            problem_types = all_problem_types(test_suite)
+            problem_types = all_problem_types(test_suite),
+            **common_args,
         )
 
 @app.route('/static/<path:path>')

mercurial