Select a template with a form and a text box. Use url_for to specify the form in the view that will process 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_template app = 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'])
MilkeyMouse May 20 '16 at 11:30 2016-05-20 11:30
source share