Added --compare and --query
This commit is contained in:
@@ -136,8 +136,6 @@ def create_app():
|
||||
file_age_seconds = c_t - f_t
|
||||
if file_age_seconds > DAYS_BEFORE_DELETION * 86400:
|
||||
os.remove(file_path)
|
||||
# TODO ADD LINKS
|
||||
# TODO TEST VARYING SIZES OF TEXT IN TABLE
|
||||
return send_file(os.path.join('media', result_id), as_attachment=True, download_name='results.tsv')
|
||||
|
||||
order_by_display = request.args.get('order_by')
|
||||
@@ -183,7 +181,6 @@ def create_app():
|
||||
|
||||
# handling input
|
||||
if 'file' in request.files and request.files['file']:
|
||||
# TODO ADD OPTION FOR MULTIPLE FILES - ZIP!
|
||||
# store file
|
||||
f = request.files['file']
|
||||
input_path = os.path.join('media', secure_filename(f.filename))
|
||||
@@ -271,9 +268,34 @@ def create_app():
|
||||
if 'root_restriction' in form and form['root_restriction']:
|
||||
configs['root_whitelist'] = form['root_restriction'].split('|')
|
||||
|
||||
configs['query'] = None
|
||||
if 'query' in form and form['query']:
|
||||
configs['query'] = form['query']
|
||||
configs['tree_size'] = '0'
|
||||
else:
|
||||
configs['query'] = None
|
||||
|
||||
# handling input
|
||||
if 'compare_file' in request.files and request.files['compare_file']:
|
||||
# store file
|
||||
f = request.files['compare_file']
|
||||
input_path = os.path.join('media', secure_filename(f.filename))
|
||||
f.save(input_path)
|
||||
|
||||
configs['compare'] = input_path
|
||||
if 'compare_url' in form and form['compare_url']:
|
||||
validation['compare_file'] = gettext('Please insert either compare url or file, not both of them.')
|
||||
validation['compare_url'] = gettext('Please insert either compare url or file, not both of them.')
|
||||
|
||||
elif 'compare_url' in form and form['compare_url']:
|
||||
try:
|
||||
name = form['compare_url'].split('/')[-1]
|
||||
input_path = os.path.join('media', name)
|
||||
response = requests.get(form['compare_url'])
|
||||
open(input_path, "wb").write(response.content)
|
||||
configs['compare'] = input_path
|
||||
except:
|
||||
validation['compare_url'] = gettext('Incorrect URL!')
|
||||
|
||||
configs['compare'] = None
|
||||
configs['sentence_count_file'] = None
|
||||
configs['detailed_results_file'] = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user