这非常简单:我有一个ID列表,我想将其作为一系列复选框显示给用户。用户应选择所需的内容,然后检查选择了哪些内容并执行功能。这是我的代码:
app.py:
getlisteUsers(): user{
console.info('yess2')
let data;
this.http.get("http://localhost:8080/tests/getAll.php").pipe(
tap(_=> this.log(`chargement de la liste réussit`)),
catchError(this.handleError(`getlisteMotAApprendre`, [])))
.subscribe(res => data = res);
return data
}
和我的template.html:
from flask import Flask, render_template, flash, request, redirect
from wtforms import Form, TextField, TextAreaField, validators, StringField, SubmitField,widgets, SelectMultipleField
from flask_wtf import FlaskForm
app = Flask(__name__)
app.config.from_object(__name__)
@app.route("/example", methods=["GET", "POST"])
def example():
form = FlaskForm()
ids= ['a','b','c']
if request.method == 'POST':
selected_ids = request.form.getlist("ids")
if form.validate():
flash('nice')
else:
flash('something went wrong')
return render_template('example.html', form=form, ids= ids)
但是,这在我提交时会产生500错误。我要去哪里错了?十分感谢您的建议!