#!/usr/bin/python print "Content-type: text/html\n" print """ Sending image coordinates to server with ismap

Click on the image to choose a location

When you click on the image, the coordinates relative to the top left corner are added as a query string to the form action. (In this case, this script). As you click, observe the coordinates appearing in the location bar above.

Any picture will do

Up to 5 points can be chosen, and will be added to the database. Click below when done.

I'm done, show me results """ import os if os.environ.has_key('QUERY_STRING'): #not the first time called (without coords) coord = os.environ['QUERY_STRING'] import pg con=pg.connect("wireless") con.query("insert into locations values ('%s')"%coord) # presupposing one has created table locations in database wireless as follows: # create table locations (coord point); # grant select,insert on locations to apache; # point is a useful sql type, for example the following queries will find the points # within a radius of 50 of the comet's head: # select * from locations where coord <-> '230,150' <= 50; -- distance <= 50 # select * from locations where coord @ circle('230,150', 50); -- contained in object