jeudi 2 mars 2017

Error 500 - Premature end of script headers

I know this is a fairly common question but I've left no digital stone unturned and still can't find an answer that works for me.

I am running MAMP and Pythons 2.x and 3.x on a Mac running macOS Sierra. I am trying to learn Python CGI scripting and I am going through this tutorial.

So far, I am at the point where I test CGI (here). I've uploaded my file to the server with the name index.cgi, in /Applications/MAMP/cgi-bin/index.cgi. However, when navigating to http://localhost/cgi-bin/index.cgi I get 500 - Internal Server Error. This occurs regardless of whether I save as a .cgi or .py.

Here's what I've tried:

Here's the code in index.py/index.cgi:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print("Content-Type: text/plain;charset=utf-8")
print()

print("Hello World!")

Any help would be hugely appreciated!




Aucun commentaire:

Enregistrer un commentaire