Retrieve text from textarea in Flask [duplicate] Retrieve text from textarea in Flask [duplicate] flask flask

Retrieve text from textarea in Flask [duplicate]


Render a template with the form and textarea. Use url_for to point the form at the view that will handle the data. Access the data from request.form.

templates/form.html:

<form action="{{ url_for('submit') }}" method="post">    <textarea name="text"></textarea>    <input type="submit"></form>

app.py:

from flask import Flask, request, render_templateapp = Flask(__name__)@app.route('/')def index():    return render_template('form.html')@app.route('/submit', methods=['POST'])def submit():    return 'You entered: {}'.format(request.form['text'])