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

时间:2019-06-27 13:15:47

标签: python flask dropzone

我正在尝试在我的项目中实现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() }}

这是我的功能:文件名: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')

文件夹结构如下:

  • 文件夹1
    • user.py
  • 模板
    • template.html.j2
  • app.py

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

Cannot build url for endpoint folder1.upload

1 个答案:

答案 0 :(得分:0)

尝试一下:

身体部位

{{ 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')