usr bin python coding utf-8 import cgi form cgi FieldStorage name form

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python
# -*- coding: utf-8 -*-
import cgi
form=cgi.FieldStorage()
name=form.getfirst('name', 'empty')
name=cgi.escape(name)
print "Content-type: text/html"
print
print """
<html><body>
<form method="get"
action="example2.py">
Name:
<input type="text"
name="name">
<input type="submit"
value="Submit">
</form>
<p>The submitted name as "%s"</p>
</body></html> """ % name