CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-flask-wtf

tessl install tessl/pypi-flask-wtf@1.2.0

Form 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%

task.mdevals/scenario-8/

Document Upload Form

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.

Requirements

Create a Flask application with the following features:

  1. Upload Configuration: Define two upload categories:

    • Images: Allow files with extensions jpg, png, gif
    • Documents: Allow files with extensions txt, pdf, doc, docx
  2. Upload Form: Create a web form with:

    • An "image" file upload field that only accepts image files
    • A "document" file upload field that only accepts document files
    • A submit button
  3. Validation: The form should validate uploaded files using the upload set configurations. Invalid file types should trigger appropriate validation errors.

  4. Routes: Implement two routes:

    • GET /upload: Display the upload form
    • POST /upload: Handle form submission and validation
  5. Success Response: When files are successfully validated, return a simple success message showing which files were uploaded (e.g., "Uploaded: photo.jpg and report.pdf").

Test Cases

  • The form rejects an image upload field with a .txt file @test
  • The form rejects a document upload field with a .jpg file @test
  • The form accepts valid image files (jpg, png, gif) in the image field @test
  • The form accepts valid document files (txt, pdf, doc, docx) in the document field @test

Implementation

@generates

Dependencies { .dependencies }

Flask { .dependency }

Provides the web framework for building the application.

Flask-WTF { .dependency }

Provides form handling, validation, and file upload support.

Flask-Uploads { .dependency }

Provides upload set configuration for organizing file uploads by type.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/flask-wtf@1.2.x
tile.json