首页 > 解决方案 > 如何为我的传单函数引用 app.py 中的变量?

问题描述

这是 app.py 的代码:

def index():
    if request.method=='POST':
        time=request.form.get("time")
        return render_template("result.html", time=time)
    else:
        return render_template("mainpage.html")

我想在我的 result.html 代码中引用时间变量,这就是我所做的:

building = "https://data.calgary.ca/resource/c2es-76ed.geojson?issueddata=" + time

fetch(building)
.then(function(response) {
return response.json();
})
.then(function(data) {
L.geoJSON(data).addTo(mymap);
});

url("https://data.calgary.ca/resource/c2es-76ed.geojson?issueddata=") 加上时间变量将是 geoJSON 的完整 url。然而,我写的代码什么也没做。有人能帮助我吗?

标签: flaskleafletgeojson

解决方案


没关系,我只是想我必须放“{{time}}”而不是时间


推荐阅读