Python Flask Basics Character Builder Forms

Efaz Khan
Efaz Khan
5,194 Points

Does name of the function and route need to be same?

@app.route("/save", methods=['POST'])
def save():
  return redirect(url_for("index"))

Does name of the function and route need to be "save" ?

In the index.html file

<form action="{{ url_for('save') }}" method="POST">

, the "save" we used in the url_for(), is it the name for the function or the route?

1 Answer

Krishna Desai
Krishna Desai
7,977 Points

No. The name of the function and the route do not need to be the same. The route appears immediately above the function that it applies to.