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 web form for uploading documents to a content management system. The form should validate uploaded files to ensure only specific document types are accepted.
The upload form must accept the following document types:
Files with other extensions should be rejected with an appropriate error message.
Create a Flask form class with:
The form should provide clear feedback when validation fails.
Implement a Flask application with:
@generates
from flask import Flask, render_template_string, request
from flask_wtf import FlaskForm
app = Flask(__name__)
app.config['SECRET_KEY'] = 'test-secret-key'
class DocumentUploadForm(FlaskForm):
"""Form for uploading documents with extension validation."""
pass
@app.route('/', methods=['GET', 'POST'])
def upload():
"""Handle document upload form display and submission."""
pass
if __name__ == '__main__':
app.run()Provides the web framework for handling routes and requests.
Provides form handling and validation capabilities for Flask applications.