Form rendering, validation, and CSRF protection for Flask with WTForms.
72
Build a Flask API endpoint that handles user registration with profile data and avatar upload. The endpoint should accept both form data and file uploads in a single request.
Create a POST endpoint /api/register that:
The endpoint should handle:
@generates
Success response (200 OK):
{
"message": "User registered successfully",
"username": "john_doe"
}Validation error response (400 Bad Request):
{
"error": "Validation failed"
}/api/register with valid form data (username, email, password, bio) and a valid PNG avatar file returns 200 with success message @test/api/register with valid form data but missing required field (e.g., no email) returns 400 with error message @test/api/register with valid form data and an invalid file type (e.g., .txt file) returns 400 with error message @test/api/register with valid form data but no avatar file returns 200 with success message (avatar is optional) @testProvides form handling and validation for Flask applications, including support for file uploads and CSRF protection.
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