Friday, 12 October 2007

CGI whitespace...

I Just could not get rid of the stupid newlines and whitespace in front and at the back of my entry :-( Someone pointed me on a forgotten newline character, so this will do it :-)

#! /usr/bin/env python

import cgi
import cgitb; cgitb.enable()
from common import *

def process():
fields = cgi.FieldStorage()
print htmlHead()
if fields.has_key('testbox'):
print "XXX<pre>%s</pre>XXX" % fields['testbox'].value.strip('\r\n ')

print """
<form action="" method="get">
<textarea name="testbox"></textarea>
<input type="submit">

print htmlFooter()
if __name__ == '__main__':

Note: the htmlHead() and htmlFooter() functions are just the value of the html head and footer code, which live in my own library common

No comments:

Post a Comment