CGI Scripts

Joshua Macy amused at
Sat Feb 5 22:35:25 EST 2000

Are you remembering to include the extra newline required by the
protocol after a Content-type header?
try this instead:

print "Content-type: text/htmln\n\n"


Robert Rutkowski wrote:
> I'm new to programing and in an effort to learn python, I'm trying to write
> a simple text counter. The script is called with an SSI exec command. The
> path on my server is correct and the script appears to work. I receive no
> errors, and the script runs just fine locally on my machine.
> My problem is that the script returns a result via the print command. {print
> `count()`}, but when I try to run the script on my server, I get no results,
> just a blank page.
> Am I missing something? Is there a module that I need to pass the result to
> to see it in my web browser.
> -----------------------------------------------------
> #!/usr/contrib/bin/python
> #Python Counter Script
> import cgi
> import string
> def count():
>     count = open('counter.log', 'r+')
>     strhits =
>     hits = string.atoi(strhits)
>     hits = hits+1
>, 0)
>     count.write(`hits`)
>     count.close()
>     return hits
> print "Content-type: text/html"
> print
> print `count()`
> ------------------------------------------------

More information about the Python-list mailing list