escape strings : Introduction : CGI Web PYTHON TUTORIALS


PYTHON TUTORIALS » CGI Web » Introduction »

 

escape strings


#!/usr/bin/env python

import cgitb
cgitb.enable()

import cgi, os, urllib

print "Content-type: text/html"
print

print """<HTML><BODY>"""
form = cgi.FieldStorage()
if form.getfirst('data') == None:
    print "No submitted data.<P>"
else:
    print "Submitted data:<P>"
    print '<A HREF="%s?data=%s"><TT>%s</TT></A><P>' % 
            (os.environ['SCRIPT_NAME'],
             urllib.quote_plus(form.getfirst('data')),
             cgi.escape(form.getfirst('data')))
print """<FORM METHOD="GET" ACTION="%s">
Supply some data: 
<INPUT TYPE="text" NAME="data" WIDTH="40">
<INPUT TYPE="submit" NAME="submit" VALUE="Submit">
</FORM>
</BODY></HTML>""" % os.environ['SCRIPT_NAME']



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo CGI Web
» Introduction