cgi - push a page from a select menu
Mark Nottingham
mnot at pobox.com
Mon Jul 19 00:37:40 EDT 1999
Try:
import cgi
form = cgi.FieldStorage()
if form.has_key("select"):
print "Location: %s" % (form['select'].value)
print
else:
print "Content-type: text/html"
print
print "<HTML><BODY><H1>What?</H1></BODY></HTML>"
----- Original Message -----
From: TMGB <bennettt at am.appstate.edu>
Newsgroups: comp.lang.python
To: <python-list at cwi.nl>
Sent: Monday, July 19, 1999 12:44 PM
Subject: cgi - push a page from a select menu
> I am trying to use python to receive a url from a form select menu and
> then send that page back to the browser. All three of my attempts so
> far leave this error message on the web server:
>
> [18/Jul/1999:22:06:34] failure: for host ....library.appstate.edu trying
> to POST /CGI-NT_Python/goto.pyc, cgi-parse-output reports: the CGI
> program D:\...(path to python)\Python\python.exe did not produce a valid
> header (program terminated without a valid CGI header (check for core
> dump or other abnormal termination)
>
> I also get this on a web page for the third attempt: AttributeError:
> open_http
>
> The python paths are correct, I have another python form using these
> paths. I would think that the urllib would send the url requested with
> its header( if I use it correctly). I tried printing a header and still
> get this error. The URL of the page with the selector is:
>
> http://www.library.appstate.edu/saat/forms/test/
>
>
> # Author: Thomas McMillan Grant Bennett
> # webmaster at www.library.appstate.edu
> # Python script to accept a url from a form and go to that URL
> # Filename: goto.py
>
> import cgi
> import urllib
>
> form = cgi.FieldStorage()
> form_ok = 0
> if form.has_key("select"):
>
> # third attempt
> # html_page=urllib.open_http(form["select"].value)
> # print html_page
>
> # second attempt
> # html_page=urllib.urlretrieve(form["select"].value)
> # print html_page
>
> # first attempt
> # print(read(urllib.urlopen(form["select"].value)))
>
>
>
> ----------------------------------------------------------------------
> Thomas McMillan Grant Bennett Appalachian State University
> Computer Consultant II University Library
> bennettt at am.appstate.edu
> http://www.library.appstate.edu/admin/
> Voice: 828 262 6587 FAX: 828 262 3001
>
> Windows 95 is a 32-bit extension to a 16-bit patch for an 8-bit
> operating system that was originally coded for a 4-bit microprocessor.
> - Chris Dunphy Boot Magazine
>
>
>
More information about the Python-list
mailing list