Je voudrais une page html où j'utilise un bouton pour fixer une heure précise (voir ci-dessous) qui, plus tard, exécute une tâche cron via le module de flacon crontab. Comment puis-je utiliser minute
, hour
, day
, month
à l'extérieur def get_time()
sans définir les variables globales?
Ce qui est un moyen concret d'utilisation de flacon crontab ici?
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
Bouton sur la page html:
<form action="/randompage.html" method="GET">
<input type="datetime-local" name="html_time"/>
<input type="submit"/></form>