I set up a python web server by opening a terminal in a directory and doing

python -m CGIHTTPServer

There is a CGI script in the directory but when I type into the browser


The CGI script is not executed but is downloaded instead. I chmod'ed the script to 755 but still the same. What am I doing wrong?


From its documentation:

The class will however, run the CGI script, instead of serving it as a file, if it guesses it to be a CGI script. Only directory-based CGI are used — the other common server configuration is to treat special extensions as denoting CGI scripts.

The do_GET() and do_HEAD() functions are modified to run CGI scripts and serve the output, instead of serving files, if the request leads to somewhere below the cgi_directories path. [...]

cgi_directories: This defaults to ['/cgi-bin', '/htbin'] and describes directories to treat as containing CGI scripts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.