Stephane
Stephane

Reputation: 5078

End of script output before headers

When I create the file test.py (see code below) in an editor on Windows (I tried Netbeans, PyCharm and Notepad++) and upload it to the server (Ubuntu) I receive this error:

End of script output before headers: test.py

But when I create the file directly on the server using vi command line editor the page is displayed without any error. Any idea how to fix this issue ?

Here's the code for test.py

#!/usr/bin/python

# send content type
print("Content-Type: text/html\n\n")

print("Good")

Upvotes: 1

Views: 1372

Answers (1)

EbraHim
EbraHim

Reputation: 2349

I think that's because of windows carriage return characters.

These are two characters:

\r is carriage return;
\n is line feed.

Two characters combined represent a new line on Windows. Whereas on Linux, \n represents new line.

Notepad++ has an option to specify which format you want to use:

Go to Settings -- > Preferences and the choose linux:

enter image description here

Upvotes: 1

Related Questions