Home > Net >  Get HTML div id in python [Flask web application]
Get HTML div id in python [Flask web application]

Time:10-31

So I am making a web app using Flask. And I want the app.py file to get the id of an html div from the index.html file

<td><a href="/edit" id="{{ i 1 }}">Edit</a>&nbsp&nbsp&nbsp&nbsp<a href="/delete">&#10006;</a></td>

the {{ i 1 }} is in jiinja format. I want that to be sent to app.py when Edit is clicked

CodePudding user response:

maybe href="/edit?{{i 1}}" - Ouroborus

Good ideea.

<td>
    <a href="/edit/?id={{i 1}}">Edit</a>
    &nbsp&nbsp&nbsp&nbsp
    <a href="/delete">&#10006;</a>
</td>

and the backend:

@app.route('/edit/')
def edit():
    Id = request.args.get("id")
    # ...
  • Related