Could not build url for endpoint 'uploaded_file' with values ['filename']. 问题

第一次学flask,在尝试flask文档中的上传文件时出现报错

Could not build url for endpoint 'uploaded_file' with values ['filename']. Did you mean 'upload_file' instead?

 文档代码

@app.route('/', methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            return redirect(url_for('uploaded_file',
                                    filename=filename))
    return '''
    
    Upload new File
    

Upload new File

'''

 最后发现是url_for函数要求参数内的函数名和route下的函数名不一样。。

文档也会出错的吗。。

 

你可能感兴趣的:(flask)