I'm following this tutorial on how to set up file uploading webservice using Flask。下面是我的代码片段。我可以看到def upload_file():获得了正确的文件名并允许它通过,但是,实际保存文件的行没有执行,我收到“Internal server error(500)”响应。问题似乎是在磁盘上实际存储文件。在
我还需要做些什么来设置我的web服务来使用Flask保存接收到的文件?
已更新-下面的代码现在起作用from flask import Flask
from flask import Response, jsonify, request, redirect, url_for
#persistent storage in dictionary
import shelve
#printing ip of host
import socket
#file uploading
import os
from werkzeug.utils import secure_filename
#serving files that were uploaded
from flask import send_from_directory
#mac-specific relative path to the script's location
UPLOAD_FOLDER = './audio'
ALLOWED_EXTENSIONS = set(['txt', 'm4a', 'mp4'])
#configuration
app = Flask(__name__)