def service_download(abkey): ab = Abstract.get_by_id(int(abkey)) if ab is not None: response = make_response(ab.abstract) response.headers['Content-Disposition'] = 'attachment; filename=' + str(ab.filename.replace(" ", "_")) response.headers['Content-Type'] = str(ab.mimetype) return response else: return "Blob not found"
def submit(): if request.method == 'POST': file = request.files['abstract'] MAX_IMAGE_SIZE = 1024 * 1024 if file: filestream = file.read() if len(filestream) > MAX_IMAGE_SIZE: return "Too large abstract size (must be less than 1 MB)" else: ab = Abstract() ab.email = request.form['email'] ab.name = request.form['name'] ab.subject = request.form['subject'] ab.abstract = db.Blob(filestream) ab.filename = file.filename ab.mimetype = file.mimetype ab.put() return redirect('/thanks') else: return "Not file attached" else: return render_template('submission/abstracts.html')
def service_subject(subject_id): ab = Abstract.query() qabs = ab.filter(Abstract.subject==subjects[int(subject_id)]).fetch() return render_template('submission/get_abstracts_by_subject.html', qabs=qabs, subject=subjects[int(subject_id)])