【发布时间】:2017-06-22 03:50:13
【问题描述】:
我正在使用 Flask 0.12 和 Python 3.6 创建一个简单的应用程序,当单击提交按钮时,它将在另一个页面中显示所选项目。
主要的 Flask 应用程序位于 app.py 中:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/result', methods=['POST'])
def result():
return render_template('result.html')
这会使用 Bootstrap 呈现以下网页:
<h1>Example Page</h1>
<p>Choose the options in the form below then submit your selections.</p>
<form action="">
<div class="form-group">
<label for="vehicle">Vehicle</label>
<select id="vehicle" class="form-control">
<option>truck</option>
<option>car</option>
<option>van</option>
</select>
</div>
<div class="form-group">
<label for="year">Year</label>
<select id="year" class="form-control">
<option>1972</option>
<option>1999</option>
<option>2010</option>
</select>
</div>
</form>
<br>
<button type="submit" class="btn btn-default">Submit</button>
当点击提交按钮时,如何让 Flask 在我的results.html 模板中显示所选项目?
【问题讨论】:
标签: python html twitter-bootstrap-3 flask