I haven't tried it but, this should work and it's a simple enough example
# In the default controller
def locateme():
import json
from gluon.tools import fetch
location_data = json.loads(fetch('http://ipinfo.io/%s/json' % request.
client))
return location_data
# In the view default/locateme.html
{{extend 'layout.html'}}
<dl>
<dt>City</dt>
<dd>{{=city}}</dd>
<dt>Region</dt>
<dd>{{=region}}</dd>
<dt>Country</dt>
<dd>{{=country}}</dd>
</dl>
Then you'll probably need to add some checking for cases where the API
doesn't return a city/region/country
--
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.