In flask function, how to I get where the POST request is from? From which .html or which form?
I have a function in .py
@app.route("/mark_read", methods=['GET', 'POST'])
def mark_read():
so when it gets a POST request, it will extract data and delete corresponding rows in my .db file.
I have multiple .html and many of them have a delete
button, instead of write many function to deal with each single case, I want to just use def mark_read():
to deal with all delete request. But how do I know where the delete is from so I can go to the correct table in my .db to perform deletion. The extracted data is not representative so I cannot use extracted data to decide the appropriate table?
For example, we can use
identifier = request.form['set_mark']
to get the value of an element with name set_mark
, is there a similar way to get which form it is? Maybe something like:
<form action="{{ url_for('mark_read') }}" method="POST" name="form_name" value="form1">
then I can get which form is it by
identifier = request.form['form_name'] # form1