我想要做的就是从我的网络用户输入中获取context_answers
和treatment_answers
并将其带到Flask上。 (我对此很新,抱歉我对自己的所作所为含糊不清)
`context_answers = {"a":[1], "b":[2], "c":[3], "d":[4]}
treatment_answers = {"y":[10]}`
我能够让context_answers做以下事情:
`methods: {
handleSubmit() {
axios.post("/submit_survey", this.context_answers)
}
}`
并在烧瓶上
`@app.route("/submit_survey", methods=["POST"])
def submit_survey():
context = request.get_json(force=True)
context_df = pd.DataFrame.from_dict(context)`
但是你如何在相同的axios post方法中得到this.treatments_answers
?在submit_survey
?
我想创建一个包含以下内容的数据框:
a b c d y
1 2 3 4 10
非常感谢!
如果你想要过去许多参数,你可以这样做:
methods: {
handleSubmit() {
axios.post("/submit_survey", {context_answers: this.context_answers,
treatments_answers: this.treatments_answers})
.then(
(response) => { console.log(response) },
(error) => { console.log(error) }
)
}
}
或试试这个:
methods: {
handleSubmit() {
axios.post("/submit_survey", {context_answers: this.context_answers,
treatments_answers: this.treatments_answers})
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
});
}