Don't Want Visitor To See Nuttin'

Victor Subervi victorsubervi at gmail.com
Wed Mar 9 16:01:22 EST 2011


Hi;
I have this code:

#!/usr/bin/python

import datetime, Cookie, random
import time, string
import cgitb; cgitb.enable()
import cgi
import sys,os
sys.path.append(os.getcwd())

def index():
  form = cgi.FieldStorage()
  referrer = form.getfirst('referrer', '')
  expiration = datetime.datetime.now() + datetime.timedelta(days=30)
  cExpires = expiration.strftime("%a, %d-%b-%Y %H:%M:%S EST")
  cPath = '/' # could be specific folder in site
  cComment = '%s' % referrer
  cDomain = ''
  cMaxAge = 30 * 24 * 60 * 60
  cVersion = 1
  print "Content-Type: text/html"
  print
  print '''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
'''
  ourTime = str(time.time())
  cookie = os.environ.get('HTTP_COOKIE')
  if not cookie:
    cookie = string.replace(ourTime, '.', '')
    cookie = Cookie.SimpleCookie()
    cookie['lastvisit'] = ourTime
    cookie['lastvisit']['expires'] = cExpires
    cookie['lastvisit']['path'] = cPath
    cookie['lastvisit']['comment'] = cComment
    cookie['lastvisit']['domain'] = cDomain
    cookie['lastvisit']['max-age'] = cMaxAge
    cookie['lastvisit']['version'] = cVersion
  else:
    cookie = Cookie.SimpleCookie(cookie)
    cookie = string.replace(string.split(str(cookie['lastvisit']), '=')[1],
'.', '')
    cookie = cookie[:-1]
  print 'Content-Type: text/html'
  print
  print '''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Maya 2012: Transform At the Source</title>
<SCRIPT language="JavaScript">
<!--
'''
  print 'window.location="preloader.py?referrer=%s&width=" + screen.width;'
% referrer
  print '''
//-->
</SCRIPT>
'''
  cookie.load(cookie)
  print '</head>\n<body bgcolor="#000000">\n</body>\n</html>'

index()


The problem is that it prints "Content-Type: text/html" to the screen for a
split-second on a white background (despite the fact that I explicitly
declare the bgcolor as black). I don't want the visitor to see that. If
necessary, make the bgcolor black so they don't see it. What do?
TIA,
Beno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110309/e55e2439/attachment.html>


More information about the Python-list mailing list