Skip to content

0.2.0

Latest

Choose a tag to compare

@Tech1kTech1k released this 01 Jun 06:15

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 as TURNSTILE_<OPTION> or as a keyword argument to Turnstile(...), and is rendered as the matching data-* attribute. The long-requested TURNSTILE_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 inspect error-codes, challenge_ts, and hostname (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 return False instead of raising.
  • Multiple Turnstile instances 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.py to pyproject.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.