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

  • SEARCH
  • Home
  • 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
  • 2 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

This question has been asked before...but I can't seem to find the exact answer
This question has been asked before, but not with this exact issue. I have
I know this question has been asked before, but I've tried everything I could
I think probably this question has been asked/answered several times before my post. But
I'm not sure if this question has been asked before but what are the
Ok guys I know this question has been asked before but I am very
I know this question has been asked so many times before but I couldn't
I know this exact question has been asked , but the solution posted there
I don't know if this exact question has been asked, if so I am
This question has already been asked but I am stuck with the most basic

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.