Work with Flask- Script and cron jobs

So, I meant creating a cron job on my prototype Flask application running on Heroku. I found on the Internet that the best way is to use Flask-Script, but I see no reason to use it. Do I get easier access to my application logic and storage information? And if I use Flask-Script, how can I organize it around my application? I am using it right now to start my server without knowing the benefits. My folder structure is as follows:

/app /manage.py /flask_prototype all my Flask code 

Should I put 'script.py' to launch Heroku's scheduler in the application folder at the same level as manage.py? If so, will I get access to the models defined in flask_prototype?

Thanks for any info.

+4
source share
1 answer

Flask-Script provides only a framework in which you can create script (s). This does not give you better access to the application than what you can get when writing a stand-alone script. But it handles several mundane tasks for you, such as command line arguments and help output. It also dumps all of your scripts into a single, consistent script command-line wizard (this is manage.py if it's not clear).

As for the placement of the script, this is not a big deal. As long as manage.py can import it and register it using Flask-Script and that your script can import what it needs from the application, everything will be fine.

+2
source

Source: https://habr.com/ru/post/1487186/


All Articles