Example #1
0
def create():
    form = NewPredictionForm(request.form)
    if form.validate_on_submit():
        flash(form.data.data)
        Job.create(name='fruits',
                   data=form.data.data,
                   current_user=current_user)
    return redirect(url_for('index.dashboard'))
def create_job(name, func, args=None, seconds=0, minutes=0):
    run_date = datetime.now() + timedelta(seconds=seconds, minutes=minutes)

    job = Job.create(name=name, run_date=run_date)

    if args is None:
        args = [job.id]
    else:
        args.insert(0, job.id)

    scheduler.add_job(id=str(job.id),
                      func=func,
                      args=args,
                      trigger='date',
                      run_date=run_date)

    return job