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

Multi-Language Contact Form

Build a simple web application that displays a contact form with internationalization support for English and Spanish. The form should validate user input and display error messages in the user's preferred language.

Requirements

Create a Flask application with the following features:

  1. Language Selection: Support two languages - English (en) and Spanish (es). The application should detect the language from a query parameter lang (e.g., /contact?lang=es), defaulting to English if not specified.

  2. Contact Form: Create a form with the following fields:

    • Name (required, text input)
    • Email (required, must be a valid email address)
    • Message (required, text area, minimum 10 characters)
    • Submit button
  3. Validation Messages: When the form fails validation, error messages should be displayed in the appropriate language:

    • For English: Use standard English validation messages
    • For Spanish: Display Spanish translations of validation messages
  4. Form Rendering: Create a template that displays the form and shows validation errors when present.

Implementation Notes

  • The application should have a single route /contact that handles both GET (display form) and POST (process submission) requests
  • On successful form submission, display a success message in the appropriate language
  • Use appropriate internationalization practices for form validation messages

Test Cases

  • Submitting an empty form displays validation error messages in English by default @test
  • Submitting an empty form with ?lang=es displays validation error messages in Spanish @test
  • Submitting a valid form shows a success message in the correct language @test
  • Submitting a form with an invalid email address shows an email validation error in the correct language @test

@generates

Dependencies { .dependencies }

Flask-WTF { .dependency }

Provides form handling and CSRF protection for Flask applications.

Flask-Babel { .dependency }

Provides internationalization and localization support for Flask applications.

Version

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