[web2py] Re: Help about the restful api
I created this controller named api, as seen in you video. @request.restful() def place(): def GET(id): place = db.place(id) return place.as_dict() if place else None def POST(name, description): return db.place.validate_and_insert( name = name, description = description) def PUSH(place,name): db.place[place].update_record(name = name) return dict() #delete place by name def DELETE(name): del db.place(name) return dict() return locals() when i call in url localhost/appname/api/place/1, it only makes the GET method for the id=1 of the place, and then for the POST method i did this script on the default controler: def post(): import urllib import urllib2 api_params = { 'name': request.args(0), 'description' : request.args(1), } http_response = urllib2.urlopen('http://localhost/api/place', urllib.urlencode(api_params)) return http_response I put this: http://localhost/appname/post/name_example/description_exampleand it add another place with that name and that description. And this script work perfectly. But i can not find any support for the DELETE and PUSH methods. I think i will have to do another script, but i can not find support about that on the web.
[web2py] Re: Help about the restful api
Hi, i answer it the other post. But my problem is in the client.
[web2py] Re: Help about the restful api
Is the problem how to build the client or the server? On May 18, 7:02 am, Tiago Moutinho wrote: > I just make POST method work with an script, but i still have some > doubts about PUSH, and DELETE. > > def testing(): > > import urllib > import urllib2 > params = { > 'name': request.args(0), > 'birth': request.args(1) > } > http_response = urllib2.urlopen('http://localhost/post/post_test', > urllib.urlencode(params)) > return http_response > > Does anyone have some ideas in makinh PUSH AND DELETE work??? > > On May 18, 10:31 am, Tiago Moutinho wrote: > > > > > > > > > Hi, > > > I have some difficulties on using @resquest.restful(). > > I want to do some experiments using GET, POST, PUSH and DELETE, but i can > > not make it work. > > Only GET works for me. > > > How can i do for example a def POST(name): ?? > > > I did this: > > > def POST(name): > > return db.blog.validate_and_insert(name = name) > > > cumps, > > Tiago
[web2py] Re: Help about the restful api
I just make POST method work with an script, but i still have some doubts about PUSH, and DELETE. def testing(): import urllib import urllib2 params = { 'name': request.args(0), 'birth': request.args(1) } http_response = urllib2.urlopen('http://localhost/post/post_test', urllib.urlencode(params)) return http_response Does anyone have some ideas in makinh PUSH AND DELETE work??? On May 18, 10:31 am, Tiago Moutinho wrote: > Hi, > > I have some difficulties on using @resquest.restful(). > I want to do some experiments using GET, POST, PUSH and DELETE, but i can > not make it work. > Only GET works for me. > > How can i do for example a def POST(name): ?? > > I did this: > > def POST(name): > return db.blog.validate_and_insert(name = name) > > cumps, > Tiago