How to host python cgi script with `python -m SimpleHTTPServer 8000` or `python -m CGIHTTPServer 8000`? How to host python cgi script with `python -m SimpleHTTPServer 8000` or `python -m CGIHTTPServer 8000`? python python

How to host python cgi script with `python -m SimpleHTTPServer 8000` or `python -m CGIHTTPServer 8000`?


Try with python -m CGIHTTPServer 8000.

Note that you have to move the script to a cgi-bin or htbin directory in order to be runnable.


SO doesn't allow me to comment so I'm adding this as a separate answer, addition to rodrigo's.

You can use another parameter cgi_directories which defaults to ['/cgi-bin', '/htbin']. More info here


In Python3 the command line is simply

python3 -m http.server --cgi 8000