webfront.py

changeset 41
4d87bc126368
parent 32
75f44d3063da
--- a/webfront.py	Wed Jan 31 14:45:31 2018 +0200
+++ b/webfront.py	Wed Jan 31 14:50:19 2018 +0200
@@ -1,5 +1,5 @@
 #!/usr/bin/env python3
-from flask import Flask, render_template, redirect, request
+from flask import Flask, render_template, redirect, request, abort
 from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths
 from ldcheck import read_ldraw
 from testsuite import load_tests, check_model, problem_text
@@ -17,11 +17,14 @@
         for ldconfig_ldr_path in find_ldconfig_ldr_paths(config):
             with ldconfig_ldr_path.open() as ldconfig_ldr:
                 load_colours(ldconfig_ldr)
-        model = read_ldraw(
-            file.stream,
-            name = file.filename,
-            config = config,
-        )
+        try:
+            model = read_ldraw(
+                file.stream,
+                name = file.filename,
+                config = config,
+            )
+        except:
+            abort(400)
         test_suite = load_tests()
         report = check_model(model, test_suite)
 

mercurial