Python Bottle Website Automate Tasks -
i have python app pulls data , posts api. pulls data last 15 minutes , needs run every 15 minutes.
i ended using bottle framework , running code in background of page , refreshing every 15 minutes (which i'm assuming isn't best way this).
@route('/') def index(): <run code> return '<meta http-equiv="refresh" content="900" />' how automate task, while having user friendly way turn off , on isn't dependent on having browser open?
if wanted pull data , post api every 15 minutes, wouldn't use web framework. write script infinite while loop , use sleep(). of course can bind script/function bottle url if wanted to.
edit (missed of op's requirements): if want user able select date, make form user can submit date. bottle backend spawn new process (python script) takes submitted date input. process continuously run code until user hits 'end' button , bottle backend kill process. see subprocess more information on spawning/deleting processes.
Comments
Post a Comment