A simple REST API for Cron written in Python
# python3 setup.py install
$ python3 src/app.py
POST /create
Request
curl -X POST
-H "Content-Type:application/x-www-form-urlencoded; charset=UTF-8"\
-d 'pattern=1 * * * *&command=echo "Hello World"'\
http://localhost:5000/create
Response
{
"job": {
"id": 6,
"pattern": "1 * * * *",
"command": "echo \"Hello World\"",
"description": "At 1 minutes past every hour of every day"
},
"status": "ok",
"message": "Job successfully created."
}
GET /retrieve[/id/{id}]
Request
curl -X GET http://localhost:5000/retrieve/id/1
Response
{
"jobs": [{
"id": 1,
"pattern": "1 * * * *",
"command": "echo \"Hello World!\";",
"description": "At 1 minutes past every hour of every day"
}],
"status": "ok",
"message": "Job retrieved successfully"
}
POST /update/id/{id}
Request
curl -X POST\
-H "Content-Type:application/x-www-form-urlencoded; charset=UTF-8"\
-d 'pattern=2 * * * *&command=echo "Hello World"'\
http://localhost:5000/update/id/1
Response
{
"job": {
"id": 1,
"pattern": "2 * * * *",
"command": "echo \"Hello World!\";",
"description": "At 2 minutes past every hour of every day"
},
"status": "ok",
"message": "Job updated successfully."
}
DELETE /delete/id/{id}
Request
curl -X DELETE http://localhost:5000/delete/id/1
Response
{
'status': 'ok',
'message': 'Job deleted successfully.'
}
MIT