Yes this can be done but the reason for using
@restful
def api()
def POST(parameter):
...
return locals()
is to have web2py do the mapping of args and vars in to parameter. If you
do not want this than just do:
def api():
if request.env.request_method=='POST':
...
the code is simpler has less gotchas.
On Saturday, 28 February 2015 07:07:03 UTC-6, Jon M. wrote:
>
> Dude!!! Thanks a lot!!! It worked like expected...
>
> Just for the record, in case someone face this problem.
>
> I set it up like suggested:
>
> def POST(*args, **vars):
> if (some_controller_method(vars['entry_value'])):
> print "The Output"
> print str(vars['entry_value'])
> else:
> do_something_else()
>
> Using curl in terminal used something like this:
>
> curl --user [email protected]:thepass -d "entry_value=the_value"
> http://127.0.0.1:8000/appname/default/api/entries.json
>
> Output at server terminal instance debugging messages, in case web2py.py
> was executed in terminal.
>
> The Ouptut
> the_value
>
> As followed in:
> http://www.web2pyslices.com/slice/show/1534/restful-services-with-curl-andor-python
>
> Suddenly I raised a doubt... Which one is better secure practice, the POST
> API function with the auth required and subsequent functions for the server
> to do... Or, customized methods that catch the raw info via XML for
> example. Which one is in security context, better.
>
> P.D: Sorry if it bothers, but how can someone distinguish between explicit
> or implicit JSON usage? I ask this because of the HTTP protocol and its
> relation with JSON usage, headers, processed info, tools that process
> information as XML, JSON, etc... And as we can se here and in the tutorial
> showed, the only thing related with JSON is the final part of the URL.
>
> Peace for all of you fellows! C:
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.