GeoIP2 for retrieving city and region ?

Chris Angelico rosuav at
Wed Jul 17 02:58:36 CEST 2013

On Wed, Jul 17, 2013 at 10:51 AM, Dennis Lee Bieber
<wlfraed at> wrote:
> On Tue, 16 Jul 2013 22:43:35 +0300, ??????? <nikos at> declaimed
> the following:
>>Lest say i embed inside my index.html the Javascript Geo Code.
>>Is there a way to pass Javascript's outcome to my Python cgi script somehow?
>>Can Javascript and Python Cgi somehow exchnage data?
>         Using plain CGI is going to be painful -- since /everything/ is handled
> a whole new page request. You would have to handle session cookies, etc.
>         Your "index.html" would attempt to run the JavaScript (note that some
> users may have JavaScript turned off -- how will you handle that), if it
> gets information it would have to do a "GET index2.html?lat=xxx?long=yyy"
> or something similar, which will result in a new page load on the user --
> hopefully with a cookie set so you know NOT to run the geolocation code on
> subsequent pages.
>         AJAX is a process to allow JavaScript on the browser to interact with a
> server (using XML data structures), and likely use DOM operations in the
> browser (and the last time I did something on this nature, I had to have
> different code for Internet Explorer vs Firefox, and don't know of
> Chrome/Opera share one of the others calls) to make changes on the web page
> without doing a full submit/render operation

AJAX changes the client end, but not the server (well, you might
change the server's output format to make it easier, but it's not
essential). So you *can* still use the CGI that you're familiar with.

For reference, Firefox/Chrome/Opera/Safari are all pretty much
identical for this sort of work; and the recent IEs (9, I think, and
10) are following them too. There are trivial differences, but for the
basics, it's possible to support IE8+, Chrome, Firefox back as far as
the Iceweasel from Debian Squeeze (I think that's Ff 3.5), and so on,
all from the same code. No per-browser checks required.


More information about the Python-list mailing list