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-0.0.30.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file flask_jobs-0.0.30.tar.gz
.
File metadata
- Download URL: flask_jobs-0.0.30.tar.gz
- Upload date:
- Size: 4.6 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.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30da2aec9b683d8b13b6d0fb50379396ba0ae7dd91f8d046e0e920b00c4d6c61 |
|
MD5 | 5e4837436747a0ca129ab00ba9cfe915 |
|
BLAKE2b-256 | 84ed6cdd46ecce64707d5fa3288cfd37acd46ef68fa4c26b080b6542037a671f |
File details
Details for the file flask_jobs-0.0.30-py3-none-any.whl
.
File metadata
- Download URL: flask_jobs-0.0.30-py3-none-any.whl
- Upload date:
- Size: 4.7 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.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2476fe25d912e7f28c218203d50221430c1e61cb3a9291cb74360f5337ef03a7 |
|
MD5 | 6bd503bbced9412e02010b359d44b4ff |
|
BLAKE2b-256 | 1b585ecf6dc2a13f519c6f94e76194ec3561655ec2e97b8c3b30af6fd8f663cc |