Form rendering, validation, and CSRF protection for Flask with WTForms.
72
Build a Flask application that implements CSRF-protected forms with time-limited tokens to prevent replay attacks.
Create a Flask application with CSRF protection that expires tokens after 2 minutes. The application should:
Your application needs the following endpoints:
/form: Returns an HTML form with CSRF protection/submit: Processes the form submission with CSRF validationThe form should include:
When processing submissions:
@generates
from flask import Flask
app = Flask(__name__)
@app.route('/form', methods=['GET'])
def form():
"""Return HTML form with CSRF protection."""
pass
@app.route('/submit', methods=['POST'])
def submit():
"""Process form submission with CSRF validation."""
passProvides CSRF protection with configurable time limits for Flask applications.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-flask-wtfevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10