Flask、Jinja2 - 缺少位置参数,但我提供了多个

Flask, Jinja2 - missing a positional argument, but I have supplied multiple

我已经被这个错误困扰了很长一段时间。我是 Jinja2 和 Flask 的新手,但我曾尝试弄乱我的 for 循环并在我的 main.py 中编辑内容,但无济于事。这是我到目前为止所得到的。

首先,我的main.py

# Data Science Notes Route
@app.route('/data-science/<content>')
def note(content):   
    return render_template('notes.html', content=content)

接下来,我的模板中导致错误的部分。

{% for link in category_files %}

    <h2 class="file-title"><a href="{{ url_for('note', content=get_note_content(link)) }}"
            class="file-link">{{ note_dict[link].title }}</a></h2>

    <!-- Display a description of the file -->
    <p class="file-description">{{ note_dict[link].description }}</p>

    <!-- Display the topics covered -->
    <p class="file-topics">Topics covered: {{ note_dict[link].topics }}</p>

    <!-- Display an image -->
    <img src="{{ note_dict[link].image }}" alt="">

    {% endfor %}```

The issue is that very first part with the `a` tag.  According to the error message, I am missing the **content** argument.  But it looks to me like I'm not!  Here's the error output, as well as the `dump()` output. 

[![Image of Error][1]][1]

Any aid would be greatly appreciated!  Thanks!


  [1]: https://i.stack.imgur.com/iyqN0.png

您没有在 URL 路线中包含 filepath

@app.route('/<note_title>/<filepath>', methods=['GET'])
def note(note_title, filepath):
    ....

如果您希望将文件路径作为 url 参数,则:

from flask import request
@app.route('/<note_title>', methods=['GET'])
def note(note_title):
    filepath = request.args.get('filepath')
    ....