{"library":"flask-wtf","code":"import os\nfrom flask import Flask, render_template, request, redirect, url_for\nfrom flask_wtf import FlaskForm\nfrom wtforms import StringField, SubmitField\nfrom wtforms.validators import DataRequired\n\napp = Flask(__name__)\napp.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', 'a_very_secret_key_for_dev')\n\nclass MyForm(FlaskForm):\n    name = StringField('Name', validators=[DataRequired()])\n    submit = SubmitField('Submit')\n\n@app.route('/', methods=['GET', 'POST'])\ndef index():\n    form = MyForm()\n    if form.validate_on_submit():\n        name = form.name.data\n        print(f\"Form submitted with name: {name}\")\n        # In a real app, save 'name' to a database, etc.\n        return redirect(url_for('success', name=name))\n    return render_template('index.html', form=form)\n\n@app.route('/success/<name>')\ndef success(name):\n    return f'Hello, {name}! Your form was submitted successfully.'\n\nif __name__ == '__main__':\n    # Example template content (save as templates/index.html)\n    # <form method=\"POST\" action=\"/\">\n    #     {{ form.hidden_tag() }}\n    #     <p>\n    #         {{ form.name.label }}\n    #         {{ form.name(size=30) }}\n    #         {% if form.name.errors %}\n    #             <ul class=\"errors\">\n    #                 {% for error in form.name.errors %}\n    #                     <li>{{ error }}</li>\n    #                 {% endfor %}\n    #             </ul>\n    #         {% endif %}\n    #     </p>\n    #     <p>{{ form.submit() }}</p>\n    # </form>\n    app.run(debug=True)","lang":"python","description":"This quickstart demonstrates a basic Flask application using Flask-WTF to create, render, and validate a simple form. It includes defining a `FlaskForm` subclass, rendering it in an HTML template, and processing its submission with `validate_on_submit()`.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":2},{"runtime":"python:3.9-slim","exit_code":2}]}