chahra
chahra

Reputation: 105

Run a script in background in flask

I am writing an app using Flask that runs a shell script and displays its output in a web page. This works fine. The thing is when I run the script, it takes a long time and the page is loading during the whole time that the script is executed. What I want is that the script runs in the background and when it ends it displays the result.

Is there a way to do that?

Upvotes: 0

Views: 1267

Answers (1)

Remyr
Remyr

Reputation: 68

You can render a simple html file at your default route that make an Ajax request to a specific route which will start your script and when the script is finished return the data and catch them in your ajax request to display the data on your page. During the process of your script you can display a loader to show that something is happening

Upvotes: 1

Related Questions