1

I'm running a web server on Flask and I want to render an html (index.html) after the script createHTML.py has finished

@app.route('/scan')
def cakes():
    os.system('python3 createHTML.py')
    return render_template('index.html')

Since this scripts takes way too long I'm getting an error saying that the website is not sending any information.

How could I stop this? Is there a way to make the website wait until the script is done to display the page?

This is the html that's running on the button:

<div style="text-align:center;">
    <button href="scan" id="realScanButton" type="button">Scan Network</button>
</div>

And this is the script that redirects to the python function:

<script>
$( document ).ready(function() {
    $("#realScanButton").click(function() {
       clickEnBotonScan(); 
      });
});
function clickEnBotonScan(){
    $("#realScanButton").html('Scanning...');
    $("#realScanButton").attr('disabled','disabled');
    window.location.href = 'http://localhost:5000/scan';
    return true;
}

Rob
  • 2,243
  • 4
  • 29
  • 40
PaoloAgVa
  • 1,302
  • 1
  • 10
  • 21

0 Answers0