chrickso
chrickso

Reputation: 3034

Dynamic routing in flask & order of operations when processing routes

With flask I'm hoping to do something like

mydomain.com/groupname

Where the groupname could be anything and will be the variable used to search a database.

Problem is, I will also need this URL 'slot' to direct differently if any number of specific keywords are hit.

I assume placing the /keyword above the /dynamic will cause it to bounce out before it gets to the "process as variable" code, but is this the best/only way to accomplish this? Does it stop once it hits the first route match or does it go through all routing options and determine the best match?

I do not want to do /group/name.

Thanks !

Upvotes: 1

Views: 1213

Answers (1)

Alex Vidal
Alex Vidal

Reputation: 4108

Do you mean that you want to have multiple routes with /groupname/ effectively as a wildcard? By creating those additional routes before the wildcard route then yes, those will be matched first and then executed.

I'm not sure exactly what you do differently on those specific keywords, but you could also match just the wildcard and have specific handling in the view function for those keywords.

Upvotes: 2

Related Questions