调用 dropzone 时未创建端点。创建

Endpoint not getting created upon calling dropzone.,create

我正在尝试在我的项目中实施 dropzone 以上传多张图片。但显然,当我调用 dropzone.create(action='') 时,我不断收到 url 未构建的错误。下面是我做的实现细节。

这是我的 css 代码文件名:template.html.j2

{% block style %}
{{ dropzone.load_css() }}
{{ dropzone.style('border: 2px dashed #0087F7; margin: 10%; min-height: 400px;') }}
{% endblock %}

这是 dropzone 的导入:

{% block scripts %}
<script src="{{url_for('static', filename='jsfiles/dropzone.js')}}"></script>
{% endblock %}

正文部分:

{{ dropzone.create(action=url_for('folder1.upload, id=user.id'))}}
{{ dropzone.load_js() }}
{{ dropzone.config() }}

这是我的功能:文件 name:user.py

@inspection.route('/users/<int:user__id>', methods=['GET', 'POST'])
def upload(id):
    //Some Code
    if form.validate_on_submit() and 'photo' in request.files:
      for f in request.files.getlist('photo'):
         filename = secure_filename(f.filename)
         print(filename)

    return render_template('folder/user_details.html.j2')

文件夹结构如下:

如果有人能指出为什么我总是收到此错误,那就太好了。

Cannot build url for endpoint folder1.upload

试试这个:

正文部分

{{ dropzone.create(action=url_for('folder1.user.upload, pk=user.id'))}}
{{ dropzone.load_js() }}
{{ dropzone.config() }}

user.py

@inspection.route('/users/<int:pk>', methods=['GET', 'POST'])
def upload(pk):
     //Some Code
     if form.validate_on_submit() and 'photo' in request.files:
         for f in request.files.getlist('photo'):
             filename = secure_filename(f.filename)
             print(filename)

    return render_template('folder/user_details.html.j2')