pythonflaskflask-script

Flask run script after start


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,


Solution

  • Put your code here:-

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