Hopefully there is a very simple answer to this problem. I want to get data from a POST in flask that is not your standard textfield value. The trick to this is that I want to try and find a solution without using javascript, I could easily do that but Im attempting to only use python.
This is not my specific example but instead a simplified one.
I want to get the value of "data-status"
<form action="/myurl/" method="post">
<div data-status="mydatahere" class="classname"></div>
</form>
Python
@app.route('/myurl/', methods=['POST'])
def myurl():
#python to get 'data-status' value here.
Thanks so much to anyone that can provide an answer.
You could pass it in as a URL parameter via the action attribute of your form, e.g.:
<form action="/myurl/?data-status=mydatahere" method="post">
<div class="classname"></div>
</form>
And then pick it up in flask like so:
@app.route('/myurl/', methods=['POST'])
def myurl():
#python to get 'data-status' value here as my_var variable:
my_var = request.args.get('data-status')
Not sure if this works in your situation but it is how I solved a similar problem for myself :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With