I'm trying to keep the value read in a webhook in the following webhook but the variable that takes the value does not keep it in the next webhook.
from flask import Flask
from flask import request
import os
from threading import Thread
app = Flask(__name__)
xml = ""
def send_email(xml):
print xml
return None
@app.route('/webhook', methods=['POST','GET'])
def webhook():
xml = "hola"
t = Thread(target=send_email, args=(xml,))
t.start()
print "acabando"
return '',200
@app.route('/response', methods=['POST','GET'])
def response():
print xml #Comprobar como comparto la variable.
return None
if __name__ == '__main__':
port = int(os.getenv('PORT', 5000))
app.run(debug=True, port=port, host='0.0.0.0', threaded=True)
The code receives the first call to / webhook, where it gives xml the value "hello" and opens a thread to execute a code (print the hello value). Up there all right, but now when I make the call to / response, it prints a gap, it does not print "hello" which is what I need.
Any ideas on how to make the value I get in / webhook stay to use in / response?
Thank you very much