Reputation: 5233
Say that I'm defining a user profile page in Flask:
@app.route('/user/<name>')
def user(name):
do stuff
I'd like to change the routing rules so that I can put more than just one designation in the <name>
, e.g. <name, location>
to translate to the user with that name and location, url given by /user/James-Oregon.
Upvotes: 0
Views: 505
Reputation: 43111
If I understand you correctly, you're looking for...
@app.route('/user/<name>-<location>')
def user(name, location):
# do stuff...
When using URL /user/James-Oregon
, you should get "James" for name
and "Oregon" for location
.
Note that flask is largely built off of Werkzeug, so be sure to check out the Werkzeug routing documentation as well.
Upvotes: 3