need help on pass arguments to flask-apscheduler via POST json and im trying to add job and it should return and print testing2 every 2 seconds.
this is my json post using postnam:
{
"id":"testing2",
"func":"app:run",
"args":"(testing2)",
"trigger":"interval",
"seconds":5
}
to URL :http://127.0.0.1:5000/scheduler/jobs
This is my code:
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from flask import Flask
from flask_apscheduler.utils import trigger_to_dict
from flask_apscheduler import APScheduler
def run(id):
print(str(id))
class Config:
SCHEDULER_JOBSTORES = {
"default": SQLAlchemyJobStore(url="sqlite:///job.db")
}
SCHEDULER_API_ENABLED = True
if __name__ == "__main__":
app = Flask(__name__)
app.config.from_object(Config())
scheduler = APScheduler()
scheduler.init_app(app)
scheduler.start()
app.run()
CodePudding user response:
problem solved
{ "id":"testing2", "func":"app:run", "args":"[testing2]", "trigger":"interval", "seconds":5 }