我有一个本地托管的Flask服务器和一个小型React应用程序。我尝试使用FilePond作为图像上传的简单解决方案。FilePond负责将每个映像发送到服务器。在
所以我现在遇到的问题显然是后端代码。我把服务器设置成这样,per Flask's docsUPLOAD_FOLDER='/images'
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/', methods=['GET', 'POST'])
def upload_file():
print(request.files)
if request.method == "POST":
# check if the post request has the file part
if 'file' not in request.files:
print('No file part')
return make_response("No File Part", 400)
file = request