Reding 1.99.1

Creator: railscoder56

Last updated:

0 purchases

Reding 1.99.1 Image
Reding 1.99.1 Images

Languages

Categories

Add to Cart

Description:

Reding 1.99.1

Reding======[![Build Status](https://secure.travis-ci.org/BuongiornoMIP/Reding.png?branch=master)](https://travis-ci.org/BuongiornoMIP/Reding)[![Coverage Status](https://coveralls.io/repos/BuongiornoMIP/Reding/badge.png?branch=master)](https://coveralls.io/r/BuongiornoMIP/Reding)[![PyPi version](https://pypip.in/v/Reding/badge.png)](https://crate.io/packages/Reding/)[![PyPi downloads](https://pypip.in/d/Reding/badge.png)](https://crate.io/packages/Reding/)Rating on Redis - REST API on Flask-----------------------------------Reding is a *WSGI* Python app made using the amazing Flask web framework, and one of its extension, Flask-RESTful.On Redis side, it uses the powerful sorted set data type to provide all the functionalities.Installation:-------------```pip install Reding```Some examples:--------------Let's start, my Reding is empty, no book has been voted:```curl−ihttp://localhost:5000/objects/HTTP/1.1200OKContent−Type:application/jsonContent−Length:2Date:Fri,01Feb201316:50:47GMTServer:mindflayer‘‘‘‘‘‘json[]‘‘‘Iwannagivea′10′totheamazing′CorePythonApplicationsProgramming′book(ISBN−13:978−0132678209):‘‘‘ curl -i -XPUT http://localhost:5000/objects/978-0132678209/users/gsalluzzo/ -d "vote=10"HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 110Date: Fri, 01 Feb 2013 16:57:44 GMTServer: mindflayer``````json{ "vote": 10, "when": "Fri, 01 Feb 2013 17:57:44 -0000", "user_id": "gsalluzzo", "object_id": "978-0132678209", "review": null}```Ehy hackers, I've just used a PUT call, but yes, I know, it's the first vote, I should use a POST one. Reding maps POST method on the PUT one, so the client does not need to know if it's the first time I'm voting this object.OK, '10' is too much indeed, let's change it to '9', or the author will get crazy about that:```curl−i−XPUThttp://localhost:5000/objects/978−0132678209/users/gsalluzzo/−d"vote=9"HTTP/1.1200OKContent−Type:application/jsonContent−Length:109Date:Fri,01Feb201317:03:16GMTServer:mindflayer‘‘‘‘‘‘json"vote":9,"when":"Fri,01Feb201318:03:16−0000","userid":"gsalluzzo","objectid":"978−0132678209","review":null‘‘‘Let′sseeifsomebodyvotedsomething(mymemoryislikethegoldfishone):‘‘‘ curl -i http://localhost:5000/objects/HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 79Date: Fri, 01 Feb 2013 17:05:46 GMTServer: mindflayer``````json[{ "amount": 9, "average": "9.0", "object_id": "978-0132678209", "votes_no": 1}]```Not expected... ;) Let's enter another vote:```curl−i−XPUThttp://localhost:5000/objects/978−0132678209/users/wchun/−d"vote=10"HTTP/1.1200OKContent−Type:application/jsonContent−Length:106Date:Fri,01Feb201317:08:03GMTServer:mindflayer‘‘‘‘‘‘json"vote":10,"when":"Fri,01Feb201318:08:03−0000","userid":"wchun","objectid":"978−0132678209","review":null‘‘‘Theauthorsaid′10′!Whatasurprise!:DLet′sgetthevotedbooksagain:‘‘‘ curl -i http://localhost:5000/objects/HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 80Date: Fri, 01 Feb 2013 17:09:42 GMTServer: mindflayer``````json[{ "amount": 19, "average": "9.5", "object_id": "978-0132678209", "votes_no": 2}]```There's only a book, what if I only get that one??```curl−ihttp://localhost:5000/objects/978−0132678209/HTTP/1.1200OKContent−Type:application/jsonContent−Length:78Date:Fri,01Feb201317:11:13GMTServer:mindflayer‘‘‘‘‘‘json"amount":19,"average":"9.5","objectid":"978−0132678209","votesno":2‘‘‘OrwhatifIonlygetmysinglevote?‘‘‘ curl -i http://localhost:5000/objects/978-0132678209/users/gsalluzzo/HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 109Date: Fri, 01 Feb 2013 17:12:00 GMTServer: mindflayer``````json{ "vote": 9, "when": "Fri, 01 Feb 2013 18:03:16 -0000", "user_id": "gsalluzzo", "object_id": "978-0132678209", "review": null}```Let's remove the author's one, he cheated:```curl−i−XDELETEhttp://localhost:5000/objects/978−0132678209/users/wchun/HTTP/1.1204NOCONTENTContent−Type:application/jsonContent−Length:0Date:Fri,01Feb201317:13:45GMTServer:mindflayer‘‘‘Let′sentermymom′svote,shedoesnotlikePython,sheevendoesn′tknowwhatitis...‘‘‘ curl -i -XPUT http://localhost:5000/objects/978-0132678209/users/mymom/ -d "vote=3"HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 105Date: Fri, 01 Feb 2013 17:15:38 GMTServer: mindflayer``````json{ "vote": 3, "when": "Fri, 01 Feb 2013 18:15:38 -0000", "user_id": "mymom", "object_id": "978-0132678209", "review": null}```Let's see the average, it must be decreased:```curl−ihttp://localhost:5000/objects/978−0132678209/HTTP/1.1200OKContent−Type:application/jsonContent−Length:78Date:Fri,01Feb201317:17:09GMTServer:mindflayer‘‘‘‘‘‘json"amount":12,"average":"6.0","objectid":"978−0132678209","votesno":2‘‘‘Well,stopprogrammingbooks...I′mgonnagivea′10′totheamazing′TheLordoftheRingsSketchbook′,butthistimeletmeaddareview:‘‘‘ curl -i -XPUT http://localhost:5000/objects/978-0618640140/users/gsalluzzo/ -d "vote=10&review=the ☃ loves lotr"HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 110Date: Fri, 01 Feb 2013 17:21:56 GMTServer: mindflayer``````json{ "vote": 10, "when": "Fri, 01 Feb 2013 18:21:56 -0000", "user_id": "gsalluzzo", "object_id": "978-0618640140", "review": "the ☃ loves lotr"}}```Let's see the books I voted and what I wrote about them:```☃curl−ihttp://localhost:5000/users/gsalluzzo/HTTP/1.1200OKContent−Type:application/jsonContent−Length:223Date:Fri,01Feb201317:22:55GMTServer:mindflayer‘‘‘‘‘‘json["vote":9,"when":"Fri,01Feb201318:03:16−0000","userid":"gsalluzzo","objectid":"978−0132678209","review":null,"vote":10,"when":"Fri,01Feb201318:21:56−0000","userid":"gsalluzzo","objectid":"978−0618640140","review":"the☃loveslotr"]‘‘‘...andagainallbooksvoted:‘‘‘ curl -i http://localhost:5000/objects/HTTP/1.1 200 OKContent-Type: application/jsonContent-Length: 161Date: Fri, 01 Feb 2013 17:23:51 GMTServer: mindflayer``````json[{ "amount": 10, "average": "10.0", "object_id": "978-0618640140", "votes_no": 1}, { "amount": 12, "average": "6.0", "object_id": "978-0132678209", "votes_no": 2}]```Filters (on GET's views):--------* *vote=* available on "/objects/<<string:object_id>>/" and "/objects/<<string:object_id>>/users/" interfaces.What's missing:----------------* List pagination; DONE!* List sorting; DONE!* Any suggestion?Thanks to:----------* **Redis** project at http://redis.io/;* **Flask** project at http://flask.pocoo.org/;* **Flask-RESTful** project at https://github.com/twilio/flask-restful/;* **CherryPy** project at http://cherrypy.org/ - if you wanna try it right now!;* **Buongiorno S.p.A.** -my company-, letting me open sources to the world.LICENSE-------The MIT License (MIT)Copyright (c) 2013 Buongiorno S.p.A.Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.