我正在尝试将我存储在我的 html 文件中的脚本标记内的数据获取到我的 python 文件中,以便我可以在 python 函数中使用它,有谁知道我该如何实现这一点?这是我的html代码:
<textarea id="rendezook" class="rendezook"></textarea>
<button onclick="get_text();">Valider</button>
<script>
function get_text() {
var x = document.getElementById("rendezook")
location.href = "/validate_comment?rendezook=" + encodeURIComponent(x.value);
console.log(x.value)
}
</script>
然后这是我的python文件:
@app.route('/validate_comment')
def validate_comment(item_id=None):
print("test")
print(request.args.get("rendezook"))
print("test2")
return redirect(url_for('msr_edit', item_id=72))
test 和 test2 没有被打印,所以它没有进入函数。