473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

cgi script: get the url of this page

A super simple question:

is there a standard trick to get the url of the current page in a cgi
script, or the url from which form data has been passed?? I want to
embed the name of the current page in a form field for two reasons:
(1) sometimes I want to send form data to the current page;
(2) sometimes I want to know where the daa came from, so I can add
that information to a database.

thanks again,

Matt
-------------------------------------------
Matt Price ma********@utoronto.ca
History Department, University of Toronto
(416) 978-2094
--------------------------------------------
Jul 18 '05 #1
2 7161
In article <ma**************************************@python.o rg>, Matt Price wrote:
A super simple question:

is there a standard trick to get the url of the current page in a cgi

import os

script = os.environ["SCRIPT_FILENAME"]

Look up the print_environ() function in the cgi-module for your python
version to give you an overview of available information.
script, or the url from which form data has been passed?? I want to


Hmm. You can try HTTP_REFERER but it depends on several things (browser,
server, cgi-implementation etc.) wether this reports something useful or
not. It is probably more reliably to check REMOTE_ADDR if that would provide
enough information.

Hth,

PterK

--
Peter van Kampen
pterk -- at -- datatailors.com
Jul 18 '05 #2
On Tue, Aug 10, 2004 at 12:43:03AM +0200, Peter van Kampen wrote:
is there a standard trick to get the url of the current page in a cgi
import os

script = os.environ["SCRIPT_FILENAME"]

great, thanks for the hint. tho I think "script_filename" gives the
file name, not the internet url -- for that REQUEST_URI seems to be
better. This is great, thanks!
script, or the url from which form data has been passed?? I want to


Hmm. You can try HTTP_REFERER but it depends on several things (browser,
server, cgi-implementation etc.) wether this reports something useful or
not. It is probably more reliably to check REMOTE_ADDR if that would provide
enough information.

hmm, REMOTE_ADDR doesn't seem to show up mosto f the time;
HTTP_REFERRER works great, though, long as the fom isn't sent to the
page it came from...

thanks much!
matt

Hth,

PterK


-------------------------------------------
Matt Price ma********@utoronto.ca
History Department, University of Toronto
(416) 978-2094
--------------------------------------------
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: bhennon | last post by:
Hey all, I have a small php script that calls a random image at the following page. http://www.2006ymcanationals.com/random.php IT WORKS IF I go directly to the above link. I am trying to...
6
by: Mike Daniel | last post by:
I am attempting to use document.write(pageVar) that displays a new html page within a pop-up window and the popup is failing. Also note that pageVar is a complete HTML page containing other java...
1
by: bayouprophet | last post by:
Cant get menu script to to put linked page in the same frame. I am new to Java and I am wondering what am I doing wrong? below are my java applet file, frame.html file, and my text file and one...
4
by: Christopher Benson-Manica | last post by:
Obviously, compiliant browsers that encounter <script type="text/javascript"> <!-- // your script here // --> </script> will either execute the script or ignore it completely. However, we...
1
by: ebrandmark | last post by:
I am trying to load a SCRIPT SRC tag that will result in a document.write into a specific location in my web page but not call for the SCRIPT SRC until the end of the page (so as not to delay the...
13
by: nobody | last post by:
Hello all, I've searched just about everything and although I can see that other people are having problems, but theirs don't seem to relate, so in a last ditch attempt, my posting! Script...
8
by: Jakej | last post by:
I've been using a javascript in an html file for a banner slider, and it works as desired. But I'd like to use it on more than one page and it would be great if I could transfer the code to a .js...
4
by: Russ | last post by:
I have a form page with a submit button. When the submit is successfull (good return from web service), I insert a script to put up a message box saying "Form submitted". That works fine, but...
1
by: Larry Rebich | last post by:
I'm using some Java Script I found that supports a 'back' button on my ASP.Net page. The Asp.Net page uses a Master page. I thought I'd put the Java Script in a Java Script file . The thought was...
12
by: Marc | last post by:
Comming from JSP-HTML when I hear 'script' I think of JavaScript or perhaps VBScript. But I think in ASP.NET they mean something else? I am bit confused now. Reading a book I see the following:...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.