Skip to content

Instantly share code, notes, and snippets.

@wilsaj
Last active March 13, 2018 13:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilsaj/5817469 to your computer and use it in GitHub Desktop.
Save wilsaj/5817469 to your computer and use it in GitHub Desktop.
example of subclassing flask.Flask to change the strict_slashes default to False for url routing
import flask
class LaxFlask(flask.Flask):
def add_url_rule(self, *args, **kwargs):
if 'strict_slashes' not in kwargs:
kwargs['strict_slashes'] = False
super(LaxFlask, self).add_url_rule(*args, **kwargs)
# instantiate with LaxFlask instead of Flask
app = LaxFlask(..)
@taylortrimble
Copy link

This is perfect!!! Thank you @mplewis for looking around and finding this! I guess I wasn't looking hard enough. 😜

@taylortrimble
Copy link

And of course thanks to @wilsaj as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment