I wrote the following python code
import thread
from flask import Flask
app = Flask(__name__)
COOKIE =""
@app.route('/')
def index():
return COOKIE
def request_cookie():
global COOKIE
while 1:
%SOME CODE WHICH GET COOKIE FROM WEB SITE%
sleep 5
if __name__ == '__main__':
app.run(debug=True)
t1 = thread.start_new_thread(get_cookie(), ())
t1.start()
When I run this code. REST server starts but the thread doesn't start.
How can I fix it so that REST server starts and parallely runs the new thread to fetch cookie from a remote site.
app.run()(becauseapp.run()is endless loop which runs till you stop server)