Static Form Web Page (friends.htm) : Form : CGI Web PYTHON TUTORIALS


PYTHON TUTORIALS » CGI Web » Form »

 

Static Form Web Page (friends.htm)


<HTML><HEAD><TITLE>
CGI Demo
</TITLE></HEAD>
<BODY><H3>Friends list for: <I>NEW USER</I></H3>
<FORM ACTION="/cgi-bin/friends1.py">
<B>Enter your Name:</B>
<INPUT TYPE=text NAME=person VALUE="NEW USER" SIZE=15>
<Paragraph><B>How many friends do you have?</B>
<INPUT TYPE=radio NAME=howmany VALUE="0" CHECKED> 0
<INPUT TYPE=radio NAME=howmany VALUE="10"10
<INPUT TYPE=radio NAME=howmany VALUE="25"25
<INPUT TYPE=radio NAME=howmany VALUE="50"50
<INPUT TYPE=radio NAME=howmany VALUE="100"100
<Paragraph><INPUT TYPE=submit></FORM></BODY></HTML>

File: friends1.py

#!/usr/bin/env python

import cgi

reshtml = '''Content-Type: text/htmln
<HTML><HEAD><TITLE>
CGI Demo
</TITLE></HEAD>
<BODY><H3>Friends list for: <I>%s</I></H3>
Your name is: <B>%s</B><Paragraph>
You have <B>%s</B> friends.
</BODY></HTML>'''

form = cgi.FieldStorage()
who = form['person'].value
howmany = form['howmany'].value
print reshtml % (who, who, howmany)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo CGI Web
» Form