Don't Want Visitor To See Nuttin'
Dotan Cohen
dotancohen at gmail.com
Mon Mar 14 13:07:54 EDT 2011
On Wed, Mar 9, 2011 at 23:01, Victor Subervi <victorsubervi at gmail.com> wrote:
> 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
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
Look at the page source in the browser. Does it begin with your
"header" or the doctype declaration? I personally think that you need
an additional blank line between the header and the doctype
declaration.
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
More information about the Python-list
mailing list