Le 01/10/2015 22:30, Alex Glaros a écrit :
> This works. But is it good programming?
>
> in controller, convert into a dict:
>
> |
> location_data
> =dict(json.loads(fetch('http://ipinfo.io/%s/json'%request.client)))
> |
>
> in view:
>
> |
> {{=location_data['city']}}
> |
As Leonel said,
This works. But is it good programming?
in controller, convert into a dict:
location_data = dict(json.loads(fetch('http://ipinfo.io/%s/json' %
request.client)))
in view:
{{=location_data['city']}}
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://git
sure, it is the same
maybe I need to define the globals or location_data as a dict?
as a work-around, I can read location_data as string, but seems that a
simple answer might be available
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2p
Le 01/10/2015 21:05, Alex Glaros a écrit :
> hi Laer,
>
> it's available as can be seen from displaying contents of "location_data"
>
> {u'loc': u'38.6071,-121.4633', u'city': u'Sacramento', u'country':
> u'US', u'region': u'California', u'hostname': u'No Hostname', u'ip':
> u'159.145.7.104', u'o
4 matches
Mail list logo