I have two scripts that are running in loop independently: a simple python script that generates data
myData=0
while True:
myData = get_data() # this data is now available for Flask App
and the flask application that displays data
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world(myData):
return str(myData)
app.run()
I wish to somehow connect the two scripts, so the application displays the data produced by the python script.
myData=0
app = Flask(__name__)
@app.route('/')
def hello_world(myData):
return str(myData)
app.run() # does not return until server is terminated
while True:
myData = get_data()
When I combine the scripts as shown above, I can see that the execution does not get to the while loop (past app.run()
line) until I terminate the app.
I found a similar question here, but not not helpful, and another question here that is identical to what I am trying to do, but it also does not give me any clue. I can not find any info that tells how to make a flask application to communicate with a separately running script. Here's a similar question with no definite answer. Please, give me an insight how these two things should run together, or an example would be greatly appreciated.