如何将按钮重定向到烧瓶中的根网址?

cai*_*ver 3 flask python-3.x web

@app.route("/")
def index():
    return render_template("webpage.html")
Run Code Online (Sandbox Code Playgroud)

我的 FlaskPage.py 文件中有上述函数,我想从下面显示的“返回主页”按钮到上面的根 URL 建立一个链接。但是,url_for 不接受空字符串作为参数,并抛出错误,如下所示

<button formaction="{{ url_for('') }}">Back to Home</button>
Run Code Online (Sandbox Code Playgroud)

错误

Could not build url for endpoint ''
Run Code Online (Sandbox Code Playgroud)

提前致谢。

cai*_*ver 5

<form method="get" action="{{url_for('index')}}">
<button> Back to Home </button>
</form>
Run Code Online (Sandbox Code Playgroud)

这解决了它。