4

I followed the steps in a respose to how to Set up Python for IIS : Python on IIS: how?

But when I write my script and try running it it fails on the first line. I get this error message:

HTTP Error 502.2 - Bad Gateway The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are " File "C:\Development\Python\helloworld.py", line 1 print 'Content-Type: text/plain' ^ SyntaxError: invalid syntax ".

This is my frist attempt at python. What is going wrong?

3
  • Which python version did you use? If you're on python 3, you need parentheses: e.g., print('Content-Type: text/plain') Commented Jan 8, 2013 at 3:22
  • yes it is 3. So is it every print statement needs brackets? what's the syntax changes with 3? Commented Jan 8, 2013 at 3:28
  • See my comment below. If it satisfies your question, feel free to accept it. Commented Jan 8, 2013 at 15:39

1 Answer 1

3

So your example helloworld.py needs to be changed to:

print('Content-Type: text/plain')
print('')
print('Hello, world!')

Python 3 changed print to use function call syntax (which can be used in python 2).

Sign up to request clarification or add additional context in comments.

1 Comment

It works for me just using: print() at the top of my code, I did not need to use print('Content-Type: text/plain')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.