Local CGI programming

Didier WILLAME didier.willame at ieee.org
Fri Jul 14 08:53:24 EDT 2000


Hello all,

I need to call a CGI python script with my web browser, on my WIN NT
station (local hard drive).

To test this, I have written the following script. But the new page
(built by the python script) is not diplayed by the web browser!

Is a http service needed to perform this test?
  If yes, what minimal product propose you?
  If no, what is the error?

Thank you for your time,
Didier

--
C:\temp\user.html
--
<HTML>
  <HEAD>
  </HEAD>
  <BODY>
    <CENTER>
    <FORM METHOD="post" action="file:///C|/temp/cgi-bin/user.py">
      enter data: <INPUT TYPE="text" NAME="data" SIZE="40">
      <BR>
      <INPUT TYPE="submit" VALUE="submit!">
    </FORM>
    </CENTER>
  </BODY>
</HTML>

--
C:\temp\cgi-bin\user.py
--
import cgi

def go():
  form = cgi.FieldStorage()

  print 'Content-type: text/html\n'
  print ''
  print '<HTML><BODY>'
  if form.has_key( 'data' ) and form[ 'data' ].value != '':
    print '<H1>The data are: ', form[ 'data' ].value, '</H1>'
  else:
    print '<H1>Error! Please enter data.</H1>'
  print '</BODY></HTML>'

if __name__ == '__main__': go()



More information about the Python-list mailing list