flask 的文件上传问题!

Jun_Gold 发布于 2018/12/13 09:58
阅读 150
收藏 0

config.py

class Config:
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
    UPLOADED_PHOTOS_DEST = os.getcwd()

views.py

def file_upload(subject_id):
    form = File_Upload_Form()
    if form.validate_on_submit():
        photos = UploadSet('photos', IMAGES)
        configure_uploads(current_app, photos)
        filename = photos.save(form.file.data)
        file_url = photos.url(filename)
    return render_template('exam.html', form = form)

 

错误提示:

builtins.AssertionError

AssertionError: A setup function was called after the first request was handled. This usually indicates a bug in the application where a module was not imported and decorators or other functionality was called too late. To fix this make sure to import all your view modules, database models and everything related at a central place before the application starts serving requests.

加载中
返回顶部
顶部