I'm working on a web app where I'm running a shell script and printing live output by returning Response object. Is there a way I can redirect to another page once the shell script is done running?
@app.route("/setup", methods=['POST', 'GET'])
def setup():
def inner():
command = ["./test.bash", "exam"]
proc = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
for line in iter(proc.stdout.readline,''):
yield line.rstrip() + '<br/>\n'
return Response(inner(), mimetype='text/html')
# After this I want to redirect to another page say success.html
Or if there is a way, I can include a template within the Response object, I can include some buttons to navigate to the page I want to.
I also want to do something like:
for line in iter(proc.stdout.readline,''):
if line == "Success":
# Redirect to success.html after returning Response object with script output
else:
# Redirect to error.html after returning Response object with script
output
Is this possible? Any help is appreciated. Thanks in advance.
location.href