from flask import Flask, render_template, session, redirect, url_for @app.route(‘/‘,methods=[‘GET‘,‘POST‘]) def index(): form = NameForm() if form.validate_on_submit(): session[‘name‘] = form.name.data return redirect(url_for(‘index‘)) return render_template(‘index.html‘,form=form,name=session.get(‘name‘))
原文:https://www.cnblogs.com/alanlee1473/p/9692956.html