Skip to content

eug/cron-rest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cron-rest

A simple REST API for Cron written in Python

Install

# python3 setup.py install

Run

$ python3 src/app.py

API

Creating a job

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."
}

Retrieving jobs

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"
}

Updating a job

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."
}

Deleting a job

DELETE /delete/id/{id}

Request

curl -X DELETE http://localhost:5000/delete/id/1

Response

{
  'status': 'ok',
  'message': 'Job deleted successfully.'
}

License

MIT

About

A simple REST API for Cron written in Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published