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-9/

Photo Gallery Upload Form

A Flask web form that allows users to upload multiple photo files to create a gallery collection.

Requirements

Build a Flask application with a form that:

  • Accepts multiple image file uploads (JPG, PNG, GIF formats only)
  • Validates that at least one file is uploaded
  • Validates that each file size is between 10KB and 5MB
  • Validates that only allowed image extensions are accepted
  • Includes CSRF protection
  • Displays appropriate validation error messages

The form should have:

  • A multiple file upload field for photos
  • A text field for the gallery name
  • A submit button

Upon successful validation, the application should display a success message showing the gallery name and the count of uploaded photos.

Implementation

@generates

Tests

  • When submitting the form with valid image files (2 JPG files), the form validates successfully @test
  • When submitting the form with a file that has an invalid extension (e.g., .txt), the form validation fails with an appropriate error message @test
  • When submitting the form without any files, the form validation fails with an error message @test
  • When submitting the form with a file larger than 5MB, the form validation fails with an appropriate error message @test

API

from flask import Flask, render_template, request, flash
from flask_wtf import FlaskForm

def create_app():
    """
    Creates and configures the Flask application.
    Returns a Flask app instance.
    """
    pass

class PhotoGalleryForm(FlaskForm):
    """
    A form for uploading multiple photos to create a gallery.
    Should include fields for gallery name and multiple photo uploads.
    """
    pass

Dependencies { .dependencies }

Flask { .dependency }

Provides web framework support.

Flask-WTF { .dependency }

Provides form handling with CSRF protection and file upload validation.

Version

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