Easy way for trailing slash?


I was wondering if there is an easier/better way to handle trailing slashes in Routes?

Route('/dellscp', 'GET', generator, name='generic-idrac-scp'),
Route('/dellscp/', 'GET', generator, name='generic-idrac-scp2'),
Route('/dellscp/{tagname}', 'GET', generator, name='custom-idrac-scp'),

Basically, I want to allow a trailing slash or not. Then after the slash, I can optionally put a tagname argument. If I leave the second line out, then /dellscp/ returns a 404.


I don’t know…all of these paths get converted into Werkzeug Rules though and I remember they have some feature associated with the trailing slash. You’ll have to dig through the documentation. Maybe this is something that would warrant opening an issue if you find it’s supportable.



Just for info, Ive researched this a long time ago and according to the standard '/dellscp' and '/dellscp/' are completely different URLs, even if all frameworks on all languages use it the other way around.

It should be a way tho…


That all makes total sense. I suppose that I am just used to other frameworks that equate the two. So when something does it “correctly”, I just assumed I was missing something.

Since there currently is no option, then it seems that easiest path forward is for me to just add a line for each variation of the URL.