I am trying to find how I can pass a URL parameter (not request) into the url_for function, but I cant find it. In the following example, I need to pass the q_id through the form, as I do with incrRight. So, how can I have variables in url_for in this scenario ?
<form action="{{url_for('answer',q_id='5495eb77433f064294361ceb')}}" method="post">
<input type="text" name="incrRight" value="0">
<input type="submit"/>
</form>
This is what I have on my controller:
@app.route('/api/v1.0/question/<string:q_id>/answer', methods = ['POST'])
def answer(q_id):
incrRight = request.form.get('incrRight')
. . .
I need my html form to be able to communicate with the above function, by passing a q_id and the incrRight parameter.
GETin that case. Or do you mean in the POST body? Either way, you mean for the browser to include them as parameters?'../answer/5495eb77433f064294361ceb?incrRight=<incrRight_value>'. It'll produce'../answer/5495eb77433f064294361ceb'withincrRight=<incrRight_value>being sent in the POST body, not the URL.