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%
A Flask application that provides an endpoint for dynamically creating forms with configurable CSRF protection.
Build a Flask application that can create and validate forms with flexible CSRF settings. The application should:
Form Factory Endpoint: Create a POST endpoint /api/configure-form that accepts JSON configuration and returns form validation results
enable_csrf boolean fieldenable_csrf is true, the form should validate CSRF tokensenable_csrf is false, the form should bypass CSRF validationForm Definition: Create a simple registration form with:
username field (required, string)email field (required, string)Request Handling: The endpoint should:
{"valid": boolean, "errors": object}@generates
from flask import Flask, request, jsonify
app = Flask(__name__)
app.config['SECRET_KEY'] = 'test-secret-key'
@app.route('/api/configure-form', methods=['POST'])
def configure_form():
"""
Create and validate a form with configurable CSRF protection.
Request JSON:
{
"enable_csrf": bool,
"username": str,
"email": str,
"csrf_token": str (optional)
}
Response JSON:
{
"valid": bool,
"errors": dict
}
"""
pass
if __name__ == '__main__':
app.run(debug=True)Provides form handling and CSRF protection for Flask applications.