我是新开发者
我试图将参数传递给我在JS中创建的按钮的onclick
函数
init: function(){
this.on("addedfile", function() {
if (this.files[1]!=null){
this.removeFile(this.files[0]);
}});
this.on("complete", function () {
previewFileBtn = document.createElement('button');
previewFileBtn.id = "previewFileId";
document.querySelector("#theFile").append(previewFileBtn);
var rt = document.createTextNode("preview the file ");
var name = this.files[0].name;
console.log("name =",name);
previewFileBtn.appendChild(rt);
document.body.appendChild(previewFileBtn);
previewFileBtn.onclick = function (){console.log("preview file Clicked");
window.location.href = "{{ url_for('readpreview', name=name )}}";
}});
var readButton = document.querySelector('#read');
myDzRead = this;
readButton.addEventListener("click",function(){
myDzRead.processQueue();});
}});
@app.route("/readpreview/<name>" , methods=["GET" , "POST"])
def readpreview(name):
print(name)
return render_template('readpreview.html',df=df)
当我单击按钮“ 预览文件”
时我得到的错误呈现为((http://127.0.0.1:5000/readpreview/上的))不是({http://127.0.0.1:5000/readpreview/
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
和在控制台上
127.0.0.1/:1 Failed to load resource: the server responded with a status of 404 (NOT FOUND)
我尝试了很多事情,我不知道为什么我会一直出现此错误 html仅具有{{name}}
当我转到http://127.0.0.1:5000/readpreview/ <名称>)时..它正在工作,但
为什么我保留重定向到错误的地址?