If you've ever used a "RESTful" API and thought it would be awesome to create your own, you're in the right place. This project's goal is to show you how easy it can be to accomplish just that in Python with the most popular libraries.
Inspired by the popular TodoMVC, I would like to thank Addy Osmani for allowing me to use his interface utilizing the Backbone.js library. (My favorite...)
- web.py : (pip install web.py | easy_install web.py)
All of the servers in this project require sqlite3 library to be installed.
All of the servers can be located in their respective directories inside ./servers/
. Start the server by running the following command.
$ python main.py
http://0.0.0.0:8080/
browse to http://localhost:8080
view the server in action.
create → POST
read → GET
update → PUT
delete → DELETE
GET /todos/
will return all available todos.
[
{
"id":547201,
"title":"Take out the trash",
"completed":true
},
{
"id":547202,
"title":"Play HoN",
"completed":false,
}
]
GET /todos/547201
will return the todo with the specified ID.
{
"id":547201,
"title":"Take out the trash",
"completed":true
}
POST /todos/
will create a new todo from the parameters passed.
{
"title":"Write HoN Bot",
}
This must return 201 Created, with the current JSON representation of the todo if the creation was a success.
PUT /todos/547202
will update the todo from the parameters passed.
{
"completed":true
}
This must return 200 OK if the update was a success along with the current JSON representation of the todo.
DELETE /todos/547202
will delete the todo specified and return 204 No Content if that was successful