I would like to break out of an infinite loop using flask and a http get.
from flask import Flask, render_template, jsonify
from serialtest import get_dist
app = Flask(__name__)
def test():
while True:
print('keep going!')
@app.route('/start')
def start():
return test()
@app.route('/stop')
def stop():
# stop the function test
return 'stopped'
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000, debug=True, threaded=True)
I want to use Flask as a http server and serve a web client that can start test() with a click event and http get, then stop test() with a different click event.