How to redirect a button to root url in flask?

Viewed 1731
@app.route("/")
def index():
    return render_template("webpage.html")

I have the above function in my flaskPage.py file and I want to make a link from the Back to Home button shown below to the above root url. However, url_for doesn't accept empty string as an argument and throws an error as follows

<button formaction="{{ url_for('') }}">Back to Home</button>

Error

Could not build url for endpoint ''

Thanks in advance.

1 Answers
<form method="get" action="{{url_for('index')}}">
<button> Back to Home </button>
</form>

This solved it.

Related