Andy Froemmel andy.froemmel at
Mon Feb 24 15:08:46 CET 2003

Sorry, my mistake...

I have running a :

import BaseHTTPServer
import CGIHTTPServer

class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
    cgi_directories = ["/cgi-bin"]

PORT = 8000

httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
print "Service an Port", PORT

furthermore I send data form a HTML-Side:

<title>Beispiel-Formular für Python</title>
<body bgcolor="#ffffdf" text="#000000" link="#0000ff"
vlink="#800080" alink="#ff0000">
<h2> Ein Beispiel-Formular (CGI in Python)</h2>
<form  action="/cgi-bin/" method="post"
Die erste GUID<br>
<input type="text"  size="70"  name="GUID1">
Die zweite GUID<br>
<input type="text"  size="70"  name="GUID2">
Der erste Host<br>
<input type="text"  size="20"  name="HOST1">
Der zweite Host<br>
<input type="text"  size="20"  name="HOST2">

<input type="SUBMIT" value="Abschicken">
<input type="RESET" value="Lieber doch nicht . . .">

to the following py-script:

import cgi
import sys
import traceback
fname = 'log_cgi.txt'
fname1 = 'error_cgi.txt'
def ausgabe(g1, g2, h1, h2):
    nachricht =''
    nachricht = g1 + g2 + h1 + h2 + '\n<br>\n'
    return nachricht

# main
sys.stderr = sys.stdout
print "Content-Type: text/html\n\n"


if form.has_key("GUID1") and form.has_key("GUID2") and
form.has_key("HOST1") and form.has_key("HOST2"):
    if form["GUID1"].value != "" and
form["HOST1"].value != "":
        form_ok = 1
        g1 =  form["GUID1"].value
        g2 =  form["GUID2"].value
        h1 =  form["HOST1"].value
        h2 =  form["HOST2"].value
        content = str(g1 + g2 + h1 + h2)
        file = open(fname, 'w')
        #print "Content-Type: text/html\n\n"
        print '</title>\n</head>\n<body
bgcolor="#ffffdf" text="navy">\n'
        #print ausgabe(g1, g2, h1, h2)
        print str(g1)
    print "<html><head><title>\n"
    print "Python is calling you!\n"
    print '</title>\n</head>\n<body bgcolor="#ffffdf"
    print 'da ist noch ein Fehler'
    #print ausgabe(g1, g2, h1, h2)
    print "</body>\n</html>\n\n"

The process is running (the data form the HTML-Side are
send to the py-script and written in an txt-file)
The problem is to get the response-side.
I mean, If I send the form to the script, I get
the message:
"The page cannot be displayed". If I make a refresh
of the html-side, the right information form the "else-function"
are shown.
Why does not send the script the information from the
form back to the HTML-side??

Thanks and best regards,

More information about the Python-list mailing list