Based on thinking and research, below is a suggestion for handling exempt-paths in turnstile_middleware.py
.
Some nice things about this...
- the regex-compilation happens just once, when the webapp first loads, improving speed.
- it allows us to change a
.env
setting easily, without deploying new code. - it allows the pattern-match code in
turnstile_middleware.py
to be simple, becase regex is handling the "starts-with" or "anywhere-within" check.