0

I have a html code such as:

<form action="/labeling?id={{id}}" method="get" target="hiddenFrame">
    <input type="radio" name="options" value="x" onchange="this.form.submit()"> X<br>  
    <input type="radio" name="options" value="y" onchange="this.form.submit()"> y<br>
</form>

and the python code that gets the id of the element:

@app.route('/labeling', methods=['GET', 'POST']) def labeling():

    value = request.form['options']
    d_id = request.form['id']

but it does not sent the values of id in the GET request? why?

Alex
  • 1,914
  • 6
  • 26
  • 47

1 Answers1

0

Your id param is not form param, try:

d_id = request.args['id']

or better use id as method param:

<form action="{{ url_for('labeling', id=id) }}" method="POST" target="hiddenFrame">
    <input type="radio" name="options" value="x" onchange="this.form.submit()"> X<br>  
    <input type="radio" name="options" value="y" onchange="this.form.submit()"> y<br>
</form>

@app.route('/labeling/<int:d_id>', methods=['GET', 'POST'])
def labeling(d_id):
    value = request.form['options']
SatanDmytro
  • 537
  • 2
  • 7