[Tutor] CGI help

David Holland davholla2002 at yahoo.co.uk
Mon Jan 3 16:25:10 CET 2005


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


More information about the Tutor mailing list