Maaz Shaikh
Maaz Shaikh

Reputation: 51

how to add job by flask apscheduler api using postman

         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) 

output
Serving Flask app "view" (lazy loading)
Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
Debug mode: on
Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
Restarting with stat
Debugger is active!
Debugger PIN: 135-565-985
job add
ob add

Upvotes: 2

Views: 1721

Answers (1)

Maaz Shaikh
Maaz Shaikh

Reputation: 51

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.

Upvotes: 2

Related Questions