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.
iwill be incremented to infinity, which will not allow it to be rendered as a string. Are you trying to display a listing ofrange(n)? i.e[0, 1, 2, 3, 4, 5...]subprocess.check_output, would this be good for your use case?