Form rendering, validation, and CSRF protection for Flask with WTForms.
72
Build a Flask web application with a document upload form that validates file types using predefined upload sets. The application should support two types of documents: images and text documents, with different allowed extensions for each category.
Create a Flask application with the following features:
Upload Configuration: Define two upload categories:
Upload Form: Create a web form with:
Validation: The form should validate uploaded files using the upload set configurations. Invalid file types should trigger appropriate validation errors.
Routes: Implement two routes:
GET /upload: Display the upload formPOST /upload: Handle form submission and validationSuccess Response: When files are successfully validated, return a simple success message showing which files were uploaded (e.g., "Uploaded: photo.jpg and report.pdf").
@generates
Provides the web framework for building the application.
Provides form handling, validation, and file upload support.
Provides upload set configuration for organizing file uploads by type.
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