Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to call a function in flask that takes 1 minute to compute, how do i do this after showing the "main" template?

What I have tried:

Python
@app.route("/main")
def mainPage():
    aFunction() #takes 1 min to run
    return render_template("main.html") # shows the template after 1 minute
Posted
Updated 19-Aug-19 20:51pm

1 solution

Hello daviddoyyer32

If you intended a to have a buffer of a certain time then there are multiple ways to do it.
One of the easiest way is to use the sleep method(function) from the time package.

Code:
Python
import time
def aFunction():
    time.sleep(60) # Delay for 1 minute (60 seconds).


Hope this solves your problem. Thanks and Regards.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900