TransWikia.com

How to reference a variable in app.py for my leaflet function?

Stack Overflow Asked by Eric Cai on February 28, 2021

Here is the code for the 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")

I want to reference the time variable in my result.html code, here is what i did:

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);
});

The url("https://data.calgary.ca/resource/c2es-76ed.geojson?issueddata=") plus the time variable would be a complete url for geoJSON. However, the code i wrote did nothing. Can someone help me please?

One Answer

Nevermind, i just figure out i have to put "{{time}}" instead of time

Answered by Eric Cai on February 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP