Flask run script after start

650 Views Asked by At

Hey trying to get a script to run once flask has been started but before the first request.

Looking at @app.before_first_request method, this seems to wait for a request before running. Another possible option is using the flask_script library. Most likely will end up using this, but wanted to see if anyone had any other suggestion that didn't include needing new libraries.

Cheers,

1

There are 1 best solutions below

1
Fasil K On BEST ANSWER

Put your code here:-

 if __name__ == "__main__":
   #write your code here to execute first when the app run