Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/douglarek/restful
A RESTful sample with Flask.
https://github.com/douglarek/restful
flask restful-api
Last synced: about 5 hours ago
JSON representation
A RESTful sample with Flask.
- Host: GitHub
- URL: https://github.com/douglarek/restful
- Owner: douglarek
- License: mit
- Created: 2014-04-06T03:45:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-08-15T07:26:29.000Z (about 2 years ago)
- Last Synced: 2023-03-24T19:28:08.725Z (over 1 year ago)
- Topics: flask, restful-api
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
RESTful
=======A RESTful sample with Flask.
- get todo list:
::
> curl -i -H "Content-Type: application/json" http://restful-flask.herokuapp.com/todo/api/tasks/
HTTP/1.1 200
Content-Length: 432
Via: HTTP/1.1 GWA
Server: gunicorn/18.0
Connection: keep-alive
Date: Sun, 06 Apr 2014 06:46:25 GMT
Content-Type: application/json{
"tasks": [
{
"description": "Amazon, 360buy, Dangdang",
"done": false,
"id": 1,
"title": "Buy Books",
"uri": "http://restful-flask.herokuapp.com/todo/api/tasks/1"
},
{
"description": "Need to find a good Haskell tutorial on the web",
"done": false,
"id": 2,
"title": "Learn Haskell",
"uri": "http://restful-flask.herokuapp.com/todo/api/tasks/2"
}
]
}- create a todo item:
::
> curl -i -H "Content-Type: application/json" -X POST -d '{"title": "Learn Python", "description": "go Pythonic"}' http://restful-flask.herokuapp.com/todo/api/tasks/ -u admin:admin
HTTP/1.1 201 CREATED
Content-Type: application/json
Date: Sun, 06 Apr 2014 06:49:30 GMT
Server: gunicorn/18.0
Content-Length: 151
Connection: keep-alive{"task": {"done": false, "uri": "http://restful-flask.herokuapp.com/todo/api/tasks/3", "description": "go Pythonic", "title": "Learn Python", "id": 3}}
- lookup a single todo item:
::
> curl -i -H "Content-Type: application/json" http://restful-flask.herokuapp.com/todo/api/tasks/1
HTTP/1.1 200
Content-Length: 189
Via: HTTP/1.1 GWA
Server: gunicorn/18.0
Connection: keep-alive
Date: Sun, 06 Apr 2014 06:50:48 GMT
Content-Type: application/json{
"task": {
"description": "Amazon, 360buy, Dangdang",
"done": false,
"id": 1,
"title": "Buy Books",
"uri": "http://restful-flask.herokuapp.com/todo/api/tasks/1"
}
}- update a todo item:
::
> curl -i -H "Content-Type: application/json" -X PUT -d '{"title": "Learn Python", "description": "go Pythonic"}' http://restful-flask.herokuapp.com/todo/api/tasks/1 -u admin:admin
HTTP/1.1 200 OK
Content-Type: application/json
Date: Sun, 06 Apr 2014 06:51:49 GMT
Server: gunicorn/18.0
Content-Length: 179
Connection: keep-alive{
"task": {
"description": "go Pythonic",
"done": false,
"id": 1,
"title": "Learn Python",
"uri": "http://restful-flask.herokuapp.com/todo/api/tasks/1"
}
}- delete a todo item:
::
> curl -i -H "Content-Type: application/json" -X DELETE http://restful-flask.herokuapp.com/todo/api/tasks/1 -u admin:admin
HTTP/1.1 200 OK
Content-Type: application/json
Date: Sun, 06 Apr 2014 06:57:36 GMT
Server: gunicorn/18.0
Content-Length: 22
Connection: keep-alive{
"result": "True"
}