def zip_image(): file = FileContainer(request.files['file']) molfile = FileContainer(request.files.get('molfile')) params = extract_params(request) if file: # and allowed_file(file): tf_img = TraModel(file, molfile=molfile, params=params).convert2img() memory = to_zip_response([tf_img]) return send_file( memory, attachment_filename='spectrum.zip', as_attachment=True )
def zip_jcamp_n_img(): file = FileContainer(request.files['file']) molfile = FileContainer(request.files.get('molfile')) params = extract_params(request) if file: # and allowed_file(file): cmpsr = TraModel(file, molfile=molfile, params=params).to_composer() tf_jcamp, tf_img = cmpsr.tf_jcamp(), cmpsr.tf_img() spc_type = cmpsr.core.ncl if cmpsr.core.typ == 'NMR' else cmpsr.core.typ memory = to_zip_response([tf_jcamp, tf_img]) rsp = make_response( send_file( memory, attachment_filename='spectrum.zip', as_attachment=True ) ) rsp.headers['X-Extra-Info-JSON'] = json.dumps({'spc_type': spc_type}) return rsp
def chemspectra_file_save(): src = FileContainer(request.files['src']) dst = FileContainer(request.files['dst']) molfile = FileContainer(request.files.get('molfile')) filename = request.form.get('filename', default=None) params = extract_params(request) if dst: # and allowed_file(file): tm = TraModel(dst, molfile=molfile, params=params) tf_jcamp, tf_img = tm.convert2jcamp_img() tf_arr = [ src.temp_file(), tf_jcamp, tf_img, tm.tf_predict(), ] memory = to_zip_response(tf_arr, filename, src_idx=0) return send_file(memory, attachment_filename='spectrum.zip', as_attachment=True)