CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-flask-wtf

Form rendering, validation, and CSRF protection for Flask with WTForms.

72

0.91x
Overview
Eval results
Files

task.mdevals/scenario-2/

Document Upload Form

A simple Flask web application that allows users to upload documents with required file validation.

Capabilities

Document Upload Validation

  • When the form is submitted without a file, validation fails and returns an error @test
  • When the form is submitted with a valid file, validation succeeds and the filename is returned @test
  • When the form is submitted with an empty FileStorage object, validation fails @test

Implementation

@generates

API

from flask_wtf import FlaskForm

class DocumentUploadForm(FlaskForm):
    """
    A form for uploading documents that requires a file to be present.

    The form should:
    - Have a field named 'document' for file uploads
    - Ensure that a file is actually uploaded (not just an empty form submission)
    - Use appropriate validation to enforce file presence
    """
    pass


def process_upload(form):
    """
    Process the upload form and return the uploaded filename if validation succeeds.

    Args:
        form: A DocumentUploadForm instance populated with request data

    Returns:
        A dictionary with either:
        - {'success': True, 'filename': str} if validation passes
        - {'success': False, 'error': str} if validation fails
    """
    pass

Dependencies { .dependencies }

Flask-WTF { .dependency }

Provides form handling, file upload fields, and file validation capabilities for Flask applications.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-flask-wtf

tile.json