An easy job scheduling interface for flask projects.
Project description
An easy job scheduling interface for flask projects.
Install
pip install flask_jobs
Example Flask Project
import datetime import time from flask import Flask, render_template, redirect from flask_jobs import JobScheduler app = Flask('JobApp') jobs = JobScheduler(app) def Callback(*a, **k): print('Callback(', a, k) @app.route('/') def Index(): return render_template( 'index.html', jobs=jobs.GetJobs(), utcnow=datetime.datetime.utcnow(), ) @app.route('/add_now_job') def NowJob(): # Schedule a job to happen ASAP jobs.AddJob( func=Callback, args=('Now Job now={}'.format(datetime.datetime.utcnow()),), kwargs={'one': 'won', 'two': 'too'}, name='Now Job at {}'.format(time.asctime()) ) return redirect('/') @app.route('/add_later_job') def LaterJob(): # Schedule a job to happen once in the future dt = datetime.datetime.utcnow() + datetime.timedelta(seconds=5) jobs.ScheduleJob( dt=dt, func=Callback, args=('ScheduleJob now={}, dt={}'.format( datetime.datetime.utcnow(), dt ),), kwargs={'one': 'won', 'two': 'too'}, name='ScheduleJob Job at {}'.format(time.asctime()) ) return redirect('/') @app.route('/add_repeat_job') def Repeat(): # Schedule a job to repeat at the given interval dt = datetime.datetime.utcnow() jobs.RepeatJob( startDT=dt, # The first time to run (None if you want to start right now) func=Callback, args=('RepeatJob now={}, dt={}'.format( datetime.datetime.utcnow(), dt ),), kwargs={'one': 'won', 'two': 'too'}, name='RepeatJob Job at {}'.format(time.asctime()), seconds=10, # can also pass "weeks", "days", "minutes", "hours" ) return redirect('/') @app.route('/delete/<ID>') def Delete(ID): job = jobs.GetJob(int(ID)) job.Delete() return redirect('/') if __name__ == '__main__': app.run( debug=True, threaded=True, )
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flask_jobs-1.0.0.tar.gz
(5.5 kB
view details)
Built Distribution
File details
Details for the file flask_jobs-1.0.0.tar.gz
.
File metadata
- Download URL: flask_jobs-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ee759c72979ed5b7402ece44cc7a199f588b9ad051fc7e8da0b7cd2aa20bbba |
|
MD5 | 0e155ed2e3e0138e53ac7a56401bc70c |
|
BLAKE2b-256 | 0fe31bad4a9e1f013052dc5580a083c4d65adcf5d2121f2be0d87ef9a13cd894 |
File details
Details for the file flask_jobs-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: flask_jobs-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83fcbd652f5551c9460a7e38617155c57713e3fe8e1f47ea7281e544f2c81e79 |
|
MD5 | 4527e45ee9090d3499903b2b43fe5141 |
|
BLAKE2b-256 | 90010e81e032fb7cf6dc26b4992cb9b3796c593a5dfc0c25977133e69560eb7a |