[Tutor] CGI help

Kent Johnson kent37 at tds.net
Mon Jan 3 17:09:38 CET 2005


It sounds like maybe you are opening the HTML directly from the filesystem? You have to install the 
HTML and CGI into a web server and access them through the server. The details for this will depend 
on the web server.

Kent

David Holland wrote:
> I have written my first cgi script :-
> The .html code is :-
> <HTML><HEAD><TITLE>
> Friends CGI Demo (Static Screen)
> </TITLE></HEAD>
> <BODY><H3>Friends list for:<I>New User</I></H3>
> <FORM
> ACTION="/home/david/Documents/pyprogramming/friends1.py">
> <B>Enter your name></B>
> <INPUT TYPE=text NAME=person SIZE=15>
> <P><B>How many friends do you have ?<B>
> <INPUT TYPE = radio NAME=how many VALUE="0" CHECKED>0
> <INPUT TYPE = radio NAME=how many VALUE="10">10
> <INPUT TYPE = radio NAME=how many VALUE="25">25
> <INPUT TYPE = radio NAME=how many VALUE="50">50
> <INPUT TYPE = radio NAME=how many VALUE="100">100
> <P><INPUT TYPE=submit></FORM></BODY></HTML>
> The python code is :-
> #!/usr/bin/env python
> import cgi
> reshtml = '''Content-Type: text/html\n
> <HTML><HEAD><TITLE>
> Friends CGI Demo (dynamic screen)
> </TITLE></HEAD>
> <BODY><H3>Friends list for: <I>%s</I></H3>
> Your name is: <B>%s</B><P>
> You have <B>%s</B> friends.
> </BODY></HTML>'''
> form = cgi.FieldStorage()
> who = form['person'].value
> howmany = form['howmany'].value
> print reshtml % (who, who, howmany)
> 
> 
> Now when I open the page using konqueror and click on
> submit. Instead of the code running, it justs opens
> the .py program in a different window.
> Any ideas ? 
> 
> 
> 	
> 	
> 		
> ___________________________________________________________ 
> ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


More information about the Tutor mailing list