I am creating an application in Flask that receives an HTTPS POST message and processes the data it contains.
Once I have received the HTTPS message, I have to answer the server with a code = 200 so that it knows that I have received the message and it does not resend it to me within a few seconds. The problem I have is that more code is executed before arriving at the return and it gives time to receive 2 or 3 messages from the server before arriving at the return.
How can I send the code 200 in the middle of the code and actually receive only one message? Do I have to do a HTTPS GET even though I do not ask for anything?
app = Flask(__name__)
@app.route('/webhook', methods=['POST','GET'])''
def webhook():
req = request.form
xml = req['data']
#HOW DO I SEND A CODE 200 NOW???
info = ET.fromstring(xml)
print info[0].text
print info[1].text
print info[2].text
print info[3].text
sender = email()
return None
Thank you!