Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1097683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:28:08+00:00 2026-05-17T00:28:08+00:00

This exact question has been asked before but I am at my wits end!

  • 0

This exact question has been asked before but I am at my wits end! I’ve spend 4 hours trying to get a SIMPLE Python CGI script to work on Windows XP but I get errors. Please save my sanity!

Python Script register.py

#!c:/Python30/python.exe -u

print "Content-type: text/html" 
print "<P>Hello, World!</p>"

Script is located in:
C:\Program Files\Apache Software Foundation\Apache2.2\cgi-bin\alerter

Apache Error Log:

[Tue Sep 21 19:06:36 2010] [error] [client 127.0.0.1] Premature end of script headers: register.py
[Tue Sep 21 19:06:36 2010] [error] [client 127.0.0.1]   File "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/alerter/register.py", line 3\r
[Tue Sep 21 19:06:36 2010] [error] [client 127.0.0.1]     print "Content-type: text/html"\r
[Tue Sep 21 19:06:36 2010] [error] [client 127.0.0.1]                                   ^\r
[Tue Sep 21 19:06:36 2010] [error] [client 127.0.0.1] SyntaxError: invalid syntax\r

httpd.conf:

LoadModule cgi_module modules/mod_cgi.so

<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
    Options +ExecCGI
    AddHandler cgi-script .py
</Directory>

This should be VERY simple. Yes? I mus be missing that ONE thing that will make it finally work. I got PHP working a while back with no problems.

Any ideas? Thanks!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:28:08+00:00Added an answer on May 17, 2026 at 12:28 am

    Your error is:

    Premature end of script headers

    Note that the HTTP protocol specifies that the body of a HTTP response is separated from it’s headers by a blank line (i.e. two times a carriage return and line feed). I’d go for something like:

    import sys
    sys.stdout.write("Content-type: text/html\r\n\r\n<p>Body</p>")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this exact question has been asked , but the solution posted there
I know this question has been asked so many times before but I couldn't
I don't know if this exact question has been asked, if so I am
Apologies if this question has been asked already, but suppose we have this code
I know this exact question was asked here , but the answer didn't work
This is driving me nuts. I believe I asked this exact same question, but
I'm certain this has been asked before-in other ways-please bear with me (for a
First off, let me start by saying, I know this exact question has been
I know that different versions of this question has been asked in the past,
I know this question has been asked several times an I spent all day

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.