webfront.py

changeset 41
4d87bc126368
parent 32
75f44d3063da
equal deleted inserted replaced
40:9200664daf87 41:4d87bc126368
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 from flask import Flask, render_template, redirect, request 2 from flask import Flask, render_template, redirect, request, abort
3 from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths 3 from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths
4 from ldcheck import read_ldraw 4 from ldcheck import read_ldraw
5 from testsuite import load_tests, check_model, problem_text 5 from testsuite import load_tests, check_model, problem_text
6 6
7 app = Flask('LDCheck') 7 app = Flask('LDCheck')
15 file = request.files['file'] 15 file = request.files['file']
16 config = load_config('ldcheck.cfg') 16 config = load_config('ldcheck.cfg')
17 for ldconfig_ldr_path in find_ldconfig_ldr_paths(config): 17 for ldconfig_ldr_path in find_ldconfig_ldr_paths(config):
18 with ldconfig_ldr_path.open() as ldconfig_ldr: 18 with ldconfig_ldr_path.open() as ldconfig_ldr:
19 load_colours(ldconfig_ldr) 19 load_colours(ldconfig_ldr)
20 model = read_ldraw( 20 try:
21 file.stream, 21 model = read_ldraw(
22 name = file.filename, 22 file.stream,
23 config = config, 23 name = file.filename,
24 ) 24 config = config,
25 )
26 except:
27 abort(400)
25 test_suite = load_tests() 28 test_suite = load_tests()
26 report = check_model(model, test_suite) 29 report = check_model(model, test_suite)
27 30
28 # Amend human-readable messages into the report 31 # Amend human-readable messages into the report
29 for problem in report['problems']: 32 for problem in report['problems']:

mercurial