首页 > 解决方案 > 如何使用邮递员通过烧瓶 apscheduler api 添加作业

问题描述

         from flask import Flask
         from flask_apscheduler import APScheduler


         class Config(object):
             JOBS = [
                  {
                          'id': 'job5',
                          'func': 'f_s_api.view:job1',
                          'trigger': 'interval',
                          'seconds': 50
                   }
              ]

         SCHEDULER_API_ENABLED = True

         def job1():
           print('job add')

        if __name__ == '__main__':
               app = Flask(__name__)
               app.config.from_object(Config())
               scheduler = APScheduler()
               scheduler.init_app(app)
               scheduler.start()
               app.run(debug= True , port= 8080) 

输出
Serving Flask app “view”(延迟加载)
环境:生产
警告:这是一个开发服务器。不要在生产部署中使用它。
请改用生产 WSGI 服务器。
调试模式:在http://127.0.0.1:8080/
上 运行(按 CTRL+C 退出) 使用 stat 重新启动 调试器处于活动状态! 调试器 PIN:135-565-985 job add ob add




标签: flaskapscheduler

解决方案


enter image description here

run the flask and open the postman and http://localhost:5000/scheduler/jobs this flask apscheduler api url for add job in the form of post request then in body-->row select text type as JSON and the send the request.


推荐阅读