【发布时间】:2022-02-15 02:05:01
【问题描述】:
我正在尝试从下拉选择中获取值(玩家)。单击下拉按钮后,我希望将值“玩家”发送到烧瓶并在网站上呈现新玩家的图像。 HTML:
<form method="POST">
<div class="input-group">
<select class="custom-select" id="inputGroupSelect04" name="player" value="{{ player }}">
{% for key, value in team.items() %}
<option value={{ value }}>{{ value }}</option>
{% endfor %}
</select>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="submit">Select</button>
</div>
</div>
</form>
<img src="/static/{{ player }}.png" alt="{{ player }}">
烧瓶:
@app.route("/", methods=['POST', 'GET'])
def main_page():
player = okc[1628983]
if request.method == "POST":
print("this posted")
player = request.form.get('player')
print(request.form.get('player'))
return render_template("index.html", team=okc, player=player)
return render_template("index.html", team=okc, player=player)
【问题讨论】:
标签: html python-3.x flask bootstrap-4