I guess I am still missing something..
I wrote this, but, logged in, I get a msg that says "no json" and a
blank screen

##-- controllers/data_hose.py
from gluon.serializers import json

@auth.requires_login()

##------------------------------------
def get_data():
  sample_data = { 'key1' : 'response 1' }
  return sample_data

def data_as_json():
  stuff = get_data()
  return json( stuff )


On Feb 21, 5:34 pm, darkblue_b <[email protected]> wrote:
> I am trying it now..
>
> (fyi, Google Groups auto removes the URL in your response)
>
> On Feb 21, 4:37 pm, Massimo Di Pierro <[email protected]>
> wrote:
>
> > The easies way is
>
> > from gluon.serializers import json
>
> > @auth.requires_login()
> > def f():
> >      return json(data)
>
> > or
>
> > @auth.requires_login()
> > def f():
> >      return dict(data=data)
>
> > and call it withhttp://.....json(intthis second case you must
> > return a dict)
>
> > and call it with .json
>
> > On Feb 21, 5:14 pm, darkblue_b <[email protected]> wrote:
>
> > > Hi All- just stumbled upon web2py, glad to see it!
>
> > > I built a model that works for a client, and now simply want to return
> > > JSON *for a logged in user".. I am sure this is straightforward, but
> > > maybe someone could say it in a simple way..
>
> > > thanks in advance
> > >  -Brian

Reply via email to