Sometimes, we want to add multiple parameters in a Python Flask app route.
In this article, we’ll look at how to add multiple parameters in a Python Flask app route.
How to add multiple parameters in a Python Flask app route?
To add multiple parameters in a Python Flask app route, we can add the URL parameter placeholders into the route string.
For instance, we write
@app.route('/createcm/<summary>/<change>')
def createcm(summary=None, change=None):
#...
to create the createcm
view function by using the app.route
decorator.
We call app.route
with the URL string with the summary
and change
placeholders.
And we get the values of the parameters from the parameters in the createcm
function.
Conclusion
To add multiple parameters in a Python Flask app route, we can add the URL parameter placeholders into the route string.