Last active
March 13, 2018 13:26
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(..) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And of course thanks to @wilsaj as well!