Code:
#!C:/Python27/python.exe
import cgi
form = cgi.FieldStorage()
a=int(form.getvalue('a','0'),0)
b=int(form.getvalue('b','0'),0)
print """Content-type: text/html
<html>
<head>
<title>Greeting Page</title>
</head>
<b><h1>Welcome!</h1></b>
<body>
<script type="text/javascript">
x=%d
y=%d
function add(x,y){
document.write(eval)(x)+(eval)(y); }
function sub(x,y){
var t=(eval)(x)-(eval)(y);
document.write(t); }
function mult(x,y){
var t=eval)(x)-(eval)(y);
document.write(t); }
function div(x,y){
var t=eval)(x)/(eval)(y);
document.write(t);
document.write("<p>this is<br/>"+"<i>division.be careful!</i> ? </p>");}
</script>
<form action='project2.py'>
first number:<input type='text' name='a' />
second number:<input type='text' name='b' />
<br><input type="button" value="add them" onclick="add()" />
<input type="button" value="sub them" onclick="sub()" />
<input type="button" value="mult them" onclick="mult()" />
<input type="button" value="div them" onclick="div()" /></br>
</form>
</body>
</html>
""" % (a,b)
Comment