[Tutor] How can a CGI program get the URL that called it?

Alan Gauld alan.gauld at btinternet.com
Fri Jan 10 11:36:02 CET 2014


On 09/01/14 22:30, Terry Carroll wrote:
> How can my Python 2.7 CGI program find the URL that caused the program
> to be called?

You don't say what modules or toolkits you are using but I'll assume for 
now its the standard library cgi module?

I'm not sure what you are looking for. Is it the url that the user 
clicked on in their browser? Why would you need that dynamically,
its calling your file. You should know where your file is?
Or is your file being called from many different page links and you want 
the specific link? Usually that's done by adding a marker to the 
submitted data on the form?

If you want to create a png file and display it to the user
then you just store the file somewhere in your web site and
create an html file that has an img tag referencing that location.
You shouldn't need the calling url to do that unless you
are working across multiple web sites or somesuch.

Can you explain a bit more about the use case that requires you
to know the incoming url?


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list