def upload_endpoint(): if request.method == 'POST': if 'file' not in request.files: return jsonify({"error": boilerplate.ERROR_NO_FILE_PART}) upload_file = request.files['file'] if upload_file.filename == '': return jsonify({"error": boilerplate.ERROR_NO_SELECTED_FILE}) if upload_file and boilerplate.allowed_file( upload_file.filename, allowed_extensions=ALLOWED_EXTENSIONS): return jsonify(boilerplate.save_file(upload_file)) return boilerplate.get_upload_form()
def upload_endpoint(): if request.method == 'POST': uploaded_files = request.files.getlist("file[]") # upload_file = request.files['file'] # make upload for few files result_upload_file = {} for num, upload_file in enumerate(uploaded_files): if uploaded_files[num].filename == '': return jsonify({"error": boilerplate.ERROR_NO_SELECTED_FILE}) if uploaded_files[num] and boilerplate.allowed_file( uploaded_files[num].filename, allowed_extensions=ALLOWED_EXTENSIONS): result_done = boilerplate.save_file(uploaded_files[num]) result = {str(num): result_done} result_upload_file.update(result) return jsonify(result_upload_file) return boilerplate.get_upload_form()