Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Python / Flask / Jinja: Passing Values

I have the following situation:

I have a website where I insert a Flight with FLIGHTNO, TERMINAL and a STATUS. I list all entries from my database(MongoDB -> JSON format) via Jinja in my index.html like this:

{% for element in table %}
      <li>{{element["flightno"]}} {{element["terminal"]}}    {{element["status"]}} <a href="{{url_for("show", id=id}}">Show</a></li> 
  {% endfor %}

I created an other Flask View which I want to direct to like this:

@app.route("/show/<id>", methods=["POST", "GET"])
   def show(id):
       result = Flight.query.filter(flightno=id).first() #MongoAlchemy
       return render_template("update.html", result=result)

So my question:

How can I pass the id (which is the flightno) to the a-link tag, so I am able to get a URL like: .../update/LH-555 ?

Thanks for your help!

Comments