⛅ Cloudstile
An unofficial Cloudflare Turnstile library with both asynchronous and synchronous support out of the box.
📥 Installation
Cloudstile is available for download via PyPI. To install it, simply do:
pip install cloudstile
🎭 Example
Here are some basic examples of how to validate a user's turnstile token.
[!WARNING] These examples expect the user's IP to be transparent. If you're using something like Cloudflare's proxy service, then you'll need to access the corresponding header for your use case.
🍷 Quart (Asynchronous)
from quart import Quart, request, jsonify
from cloudstile import AsyncTurnstile
app = Quart(__name__)
turnstile = AsyncTurnstile(token="...")
@app.route("/submit", methods=["POST"])
async def submit():
body = await request.form
response = await turnstile.validate(
body.get("cf-turnstile-response", "..."),
request.remote_addr,
)
return jsonify(response.model_dump()) # <- Response is a pydantic object
🏃♀️ FastAPI (Asynchronous)
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from cloudstile import AsyncTurnstile
app = FastAPI()
turnstile = AsyncTurnstile(token="...")
@app.post("/submit")
async def submit(request: Request):
body = await request.form()
response = await turnstile.validate(
body.get("cf-turnstile-response", "..."),
request.client.host,
)
return JSONResponse(response.model_dump()) # <- Response is a pydantic object
🦥 Flask (Synchronous)
from flask import Flask, request, jsonify
from cloudstile import SyncTurnstile
app = Flask(__name__)
turnstile = SyncTurnstile(token="...")
@app.route("/submit", methods=["POST"])
def submit():
body = request.form
response = turnstile.validate(
body.get("cf-turnstile-response", "..."),
request.remote_addr,
)
return jsonify(response.model_dump()) # <- Response is a pydantic object
Metadata
Release files for cloudstile 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cloudstile-2.0.2.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cloudstile-2.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / cloudstile-2.0.2.tar.gz
| Download URL | cloudstile-2.0.2.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eeec944e8312407d1396e1f5e359384b0ac54776866f567db77851cb0dcc1c2a
|
|
BLAKE2b-256 checksum How to use checksums |
32c19d4470773a452f317404336a2858ce0385a1299b050157938e043ffbc884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.14.4 Linux/7.0.3-1-cachyos
|
Release files / cloudstile-2.0.2-py3-none-any.whl
| Download URL | cloudstile-2.0.2-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b567a9f303739a935929e0b595c26a812f4a68944bf1bd37e78c7d8fe569c257
|
|
BLAKE2b-256 checksum How to use checksums |
1e38eec1eaf4e24769ec520f66b18089494e3aa1e3061ef16c8020d881d27c13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.14.4 Linux/7.0.3-1-cachyos
|