Flask-Turnstile 0.2.0
First update in a while. Modernizes the package and adds the most-requested widget configuration, while staying fully backwards compatible with 0.1.1. No code changes are required to upgrade.
Added
- Full Turnstile widget configuration. Every Cloudflare widget option (
theme,size,language,appearance,action,cdata, callbacks, and more) can now be set via Flask config asTURNSTILE_<OPTION>or as a keyword argument toTurnstile(...), and is rendered as the matchingdata-*attribute. The long-requestedTURNSTILE_THEME(light/dark/auto) is included. See the README for the full table. get_response()method that returns Cloudflare's raw siteverify JSON, so you can inspecterror-codes,challenge_ts, andhostname(useful for logging why a challenge failed).verify()still returns a plain bool.- Type hints on the public API for editor autocomplete.
Fixed
verify()no longer hangs or crashes on network problems. Requests now use a 10s timeout (configurable per call), and connection/timeout errors returnFalseinstead of raising.- Multiple
Turnstileinstances no longer clobber each other. Configuration is now stored per-instance instead of in shared global state. - Corrected the README license badge (was mislabeled GPL; the project is MIT) and fixed broken usage examples.
Changed
- Migrated packaging from
setup.pytopyproject.toml. - Requires Python 3.9+ (dropped dead Python 2.x / 3.3 metadata); tested on 3.9–3.13.
- Modernized CI and switched PyPI publishing to trusted publishing (OIDC).
- Expanded the test suite (4 to 22 tests) and removed its dependency on live network calls.
Full backwards compatibility: existing Turnstile(app=app), verify(), get_code(), and {{ turnstile }} usage is unchanged. When no widget options are set, the rendered HTML is identical to 0.1.1.