webfront.py

changeset 122
116a81996832
parent 112
d997456985b2
child 145
fde18c4d6784
equal deleted inserted replaced
121:35b95d1806c9 122:116a81996832
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
3 from ldcheck import appname, version, version_string 3 from ldcheck import appname, version, version_string
4 from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths 4 from ldcheck import load_config, find_ldconfig_ldr_paths
5 from parse import read_ldraw 5 from parse import read_ldraw
6 from testsuite import load_tests, check_model, problem_text, all_problem_types 6 from testsuite import load_tests, check_model, problem_text, all_problem_types
7 7
8 app = Flask(appname) 8 app = Flask(appname)
9 9
35 # check if the post request has the file part 35 # check if the post request has the file part
36 if 'file' not in request.files or not request.files['file'].filename: 36 if 'file' not in request.files or not request.files['file'].filename:
37 return redirect(request.url) 37 return redirect(request.url)
38 file = request.files['file'] 38 file = request.files['file']
39 filename = file.filename 39 filename = file.filename
40 config = load_config('ldcheck.cfg') 40 config = load_config()
41 for ldconfig_ldr_path in find_ldconfig_ldr_paths(config):
42 with ldconfig_ldr_path.open() as ldconfig_ldr:
43 load_colours(ldconfig_ldr)
44 model = read_ldraw( 41 model = read_ldraw(
45 file.stream, 42 file.stream,
46 name = filename, 43 name = filename,
47 ldraw_directories = config['libraries'], 44 ldraw_directories = config['libraries'],
48 ) 45 )

mercurial