1 回答
TA贡献1828条经验 获得超4个赞
它的发生是因为您更改正在调用更改 Ajax 请求(XMLHttpRequest)内部 HTML 的路由,因此您有两个选择,第一个是更改 HTML 以响应如下:
xhr.onreadystatechange = function() {
if (xhr.readyState == XMLHttpRequest.DONE) {
document.write(xhr.responseText);
}
}
// or using query(its better to me)
$.ajax({
type: "POST",
contentType: 'application/json',
url: "/",
data: {audio_data: blob}
success:function(response){
document.write(response);
}
});
另一种是做API,不需要调用render_template,只需要在index函数中返回resultsentence(这个result需要是dict格式)
@app.route("/", methods=['POST', 'GET'])
def index():
if request.method == "POST":
#the image logic...
return make_response(resultsentence)
else:
return render_template("index.html")
这样,您将需要使用 javascript 处理前端的响应
添加回答
举报
