11 if request.method == 'POST': |
11 if request.method == 'POST': |
12 # check if the post request has the file part |
12 # check if the post request has the file part |
13 if 'file' not in request.files or not request.files['file'].filename: |
13 if 'file' not in request.files or not request.files['file'].filename: |
14 return redirect(request.url) |
14 return redirect(request.url) |
15 file = request.files['file'] |
15 file = request.files['file'] |
|
16 filename = file.filename |
16 config = load_config('ldcheck.cfg') |
17 config = load_config('ldcheck.cfg') |
17 for ldconfig_ldr_path in find_ldconfig_ldr_paths(config): |
18 for ldconfig_ldr_path in find_ldconfig_ldr_paths(config): |
18 with ldconfig_ldr_path.open() as ldconfig_ldr: |
19 with ldconfig_ldr_path.open() as ldconfig_ldr: |
19 load_colours(ldconfig_ldr) |
20 load_colours(ldconfig_ldr) |
20 model = read_ldraw( |
21 model = read_ldraw( |
21 file.stream, |
22 file.stream, |
22 name = file.filename, |
23 name = filename, |
23 ldraw_directories = config['libraries'], |
24 ldraw_directories = config['libraries'], |
24 ) |
25 ) |
25 test_suite = load_tests() |
26 test_suite = load_tests() |
26 report = check_model(model, test_suite) |
27 report = check_model(model, test_suite) |
27 |
28 |
30 object = model.body[problem['body-index']] |
31 object = model.body[problem['body-index']] |
31 problem['message'] = problem_text(problem, test_suite) |
32 problem['message'] = problem_text(problem, test_suite) |
32 problem['ldraw-code'] = object.textual_representation() |
33 problem['ldraw-code'] = object.textual_representation() |
33 else: |
34 else: |
34 report = None |
35 report = None |
|
36 filename = None |
35 return render_template('webfront.html', |
37 return render_template('webfront.html', |
36 report = report, |
38 report = report, |
|
39 name = filename |
37 ) |
40 ) |
38 |
41 |
39 @app.route('/static/<path:path>') |
42 @app.route('/static/<path:path>') |
40 def static_file(path): |
43 def static_file(path): |
41 from flask import send_from_directory |
44 from flask import send_from_directory |