Vorrei eseguire una pagina html dove utilizzare un pulsante per impostare un tempo specifico (vedi sotto), che in seguito viene eseguito un cronjob tramite il modulo pallone-crontab. Come posso utilizzare minute
, hour
, day
, month
al di fuori def get_time()
senza impostare le variabili globali?
Che cosa è un modo solido per uso pallone-crontab qui?
APP = Flask(__name__)
Bootstrap(APP)
crontab = Crontab(APP)
...
@APP.route('/randompage.html' methods = ['POST', 'GET])
def get_time():
time_req = request.args.get("html_time")
format_time = datetime.strptime(time_req, "%Y-%m-%dT%H:%M")
minute = format_time.minute
hour = format_time.hour
day = format_time.day
month = fomrat_time.month
return render_template('randompage.html', time_req=time_req)
@crontab.job()
def exe_control():
do something here
Pulsante in una pagina html:
<form action="/randompage.html" method="GET">
<input type="datetime-local" name="html_time"/>
<input type="submit"/></form>