我正在努力重新定向到另一个完全在烧瓶中的网站。我不确定是因为Flask的性质,还是因为我使用了错误的方法。我一直收到错误消息‘从源网站访问XMLHttpRequest’已被CORS策略阻止:对印前检查请求的响应未通过访问控制检查:请求的资源上不存在' access - control -Allow- origin‘头。我该怎么解决这个问题。下面是我用Python Flask编写的代码。我需要一个状态代码吗?:
返回重定向(‘(此处为https://website)’)
还有没有其他技术。我读过关于使用when浏览器包的文章,但当我将我的应用程序部署到heroku时,它似乎不起作用。有没有人能给我们提个建议。谢谢
@app.route('/test', methods=['GET','POST'])
def test():
data = request.get_json(force=True)
dataset=format(data)
model = LinearSVC().fit(tfidf_vectorizer_vectors, y_train)
new_complaint = dataset
new_complaints = ''.join(new_complaint)
print(new_complaints)
values =model.predict(fitted_vectorizer.transform([new_complaints]))
print(values)
labelling=str(values)
print(labelling)
if labelling == "['something']":
return redirect("https://www.google.co.uk/", code=302)发送数据的JAVASCRIPT:
new_arr = JSON.stringify(arr);
console.log(new_arr);
$.post("/test", new_arr);发布于 2020-07-31 07:32:38
是的,您需要一个状态代码。
return redirect("http://www.example.com", code=302)https://stackoverflow.com/questions/63182832
复制相似问题