def parse_gctx(infile): fid = File(infile, 'r') mat = fid.getNode('/0/DATA/0', 'matrix').read() rid = fid.getNode('/0/META/ROW', 'id').read() cid = fid.getNode('/0/META/COL', 'id').read() fid.close() return {'matrix': mat, 'rid': rid, 'cid': cid}
def upload_file(): """Upload a file to the database""" if not current_user.is_authenticated: flash("You need to log in or sign up before uploading file.") return redirect(url_for("login")) form = UploadFileForm() if form.validate_on_submit(): pic = form.file.data filename = generate_filename(File, pic.filename) mimetype = pic.mimetype file = File(filename=filename, file=pic.read(), mimetype=mimetype, file_owner=current_user) db.session.add(file) db.session.commit() return redirect(url_for("get_files")) return render_template("upload-img.html", form=form, logged_in=True, file=True)