Turnstile/fastapi
Hi All,
I have a small api built with fastapi and I am generating a few html pages for a front end directly using jinja templates. Trying to piece together how I would enable turnstile for a contact form before I publish it.
Seems like I need the front end portion on the client side to send to the backend on the form post, but that is where the docs seem a little confusing. Any examples or guidance apprecated or possibly point me to the correct docs. I may have missed it.
EDIT: Maybe this is best handled via a worker?
2 Replies
There is a template/example of doing it with a worker: https://developers.cloudflare.com/turnstile/reference/workers-templates/price-scraping/
Turnstile is also super close to recaptcha in design/endpoints. You get the general idea though, render it: https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/, grab the token from the calllback, and forward it to your backend to do siteverify: https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
Cloudflare Docs
Price scraping · Cloudflare Turnstile docs
The script below is applied on the root path / }} and serves a page where the Turnstile widget will be embedded.
Thanks, I ended up figuring it out.