tessl install tessl/pypi-flask-wtf@1.2.0Form rendering, validation, and CSRF protection for Flask with WTForms.
Agent Success
Agent success rate when using this tile
72%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.91x
Baseline
Agent success rate without this tile
79%
Build a Flask application with a user registration form that properly integrates CSRF protection at both the application and form levels.
Create a Flask web application with the following components:
A user registration form with the following fields:
CSRF protection must be enabled globally for the entire application using the appropriate extension.
The registration form must also include form-level CSRF protection.
Create a route /register that:
Create a route /health that is exempt from CSRF protection and returns "OK" for health checks.
The application should properly handle CSRF token validation without performing redundant checks when both global and form-level protection are active.
/register, the response contains a CSRF token field @test/register, the response is "Registration successful" @test/register, the response has a 400 status code @test/health, the response is "OK" @test/health, the response is "OK" (no CSRF check) @test@generates
# Flask application setup
from flask import Flask
app = Flask(__name__)
app.config['SECRET_KEY'] = 'test-secret-key-12345'
# Registration route
@app.route('/register', methods=['GET', 'POST'])
def register():
"""Handle user registration with CSRF-protected form."""
pass
# Health check route (CSRF exempt)
@app.route('/health', methods=['GET', 'POST'])
def health():
"""Health check endpoint without CSRF protection."""
passProvides the web framework for building the application.
Provides form handling and CSRF protection for Flask applications.
Provides form field definitions and validation support.