Wow, this should have been easy, but it just wouldn’t work:
Now I will provide my troubleshooting experiences from this morning:
Problem 1: Not Authorized to view your test script
You are not authorized to view this page You do not have permission to view this directory or page using the credentials you supplied. Please try the following: * Click the Refresh button to try again with different credentials. * If you believe you should be able to view this directory or page, please contact the Web site administrator by using the e-mail address or phone number listed on the localhost home page. HTTP 401.3 - Access denied by ACL on resource Internet Information Services Technical Information (for support personnel) * More information: Microsoft Support
Solution: Right click on your test script file (or the entire directory), select properties, select the security tab, make sure that IUSR_[your computer name] and IWAM_[your computer name] has read and execute permissions. If they are not listed, click add. If you can’t find them to add, click advanced and make sure you search the entire computer (todo: add picture)
Problem 2: Python doesn’t see my test file.
CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: C:Python24python.exe: can't open file 'C:Documents': [Errno 2] No such file or directory
Solution: Fix your application mapping:
To do this, perform the following steps:
a. In the ISM, under Internet Information Server, right-click your website and select properties
c. Click the Home Directory or Virtual Directory tab (which ever you see), and then click Configuration.
d. Edit your mapping for the .py (other other Python extension) Executable to be:
C:\Python24\python.exe -u “%s” “%s”
(use your python path of course, keep those quote marks, they’re vital!)
Problem 3: My browser keeps asking me if I want to save the test script!
My browser prompts me with:
Opening wrongcontentTest.py You have chosen to open wrongcontentTest.py which is a: Python File from: http://localhost What should Firefox do with this file? ...
Solution: Script needs to print correct content type.
The test script from the MSDN link above tells you to start with this:
print 'Status: 200 OK'
print 'Content-type: text/html'
That did not work for me. Once I changed my test script to start with:
print "Content-Type: text/html\n\n"
everything was good.
Please post any questions in the comments section. I hope my lost morning helps someone out there!