ThinkNewDev
ThinkNewDev

Reputation: 668

Why and I getting a 500 error although my python script appears to work?

#!"C:\Program Files (x86)\Ampps\python\python.exe"
import os,sys,cgi
print "Content-Type: text/plain;charset=utf-8"
form = cgi.FieldStorage()
json = form.getvalue("json")
file = open("testjson.json", "w")

file.write(json)

file.close()

print json

sys.exit()

I am running Python 2.7.2 as WSGI and other scripts appear to work.

Upvotes: 1

Views: 46

Answers (1)

falsetru
falsetru

Reputation: 369394

The last HTTP header should be followed by blank line. (The header and body should be separated by blank line)

print "Content-Type: text/plain;charset=utf-8"
print # <---- Add this line

...

# sys.exit() <--- This is not needed.

Upvotes: 1

Related Questions