Flask-APScheduler 直接提供 API,只要在配置文件里面配置 SCHEDULER_API_ENABLED =True 就行
API 如下
self._add_url_route('get_scheduler_info', '', api.get_scheduler_info, 'GET') | |
self._add_url_route('add_job', '/jobs', api.add_job, 'POST') | |
self._add_url_route('get_job', '/jobs/<job_id>', api.get_job, 'GET') | |
self._add_url_route('get_jobs', '/jobs', api.get_jobs, 'GET') | |
self._add_url_route('delete_job', '/jobs/<job_id>', api.delete_job, 'DELETE') | |
self._add_url_route('update_job', '/jobs/<job_id>', api.update_job, 'PATCH') | |
self._add_url_route('pause_job', '/jobs/<job_id>/pause', api.pause_job, 'POST') | |
self._add_url_route('resume_job', '/jobs/<job_id>/resume', api.resume_job, 'POST') | |
self._add_url_route('run_job', '/jobs/<job_id>/run', api.run_job, 'POST') |
需要加上默认的前缀 /schedule,当然修改也是可以的,配置文件里面配置 SCHEDULER_API_PREFIX ='/your_path' 就行,如
http://xxx.xxx.xxx:8080/scheduler/jobs/<job_id>/pause | |
http://xxx.xxx.xxx:8080/your_path/jobs/<job_id>/pause |