Pre-Condition:
Install Apache2, setup system path, register httpd as a service:
httpd -k install
The CGIHTTPServer module has been MERGED into http.server in Python 3
Running a Simple CGI Web Server with python3 on windows via Apache2
1. Update httpd.conf , define SRVROOT to the apache2 home path, make sure cgi_module loaded, and uncommit 'AddHandler' after adding '.py' to it;
#
# ServerRoot: The top of the directory tree under which the server's
#
Define SRVROOT "G:\Apache24"
ServerRoot "${SRVROOT}"
AddHandler cgi-script .cgi .pl .py
LoadModule cgi_module modules/mod_cgi.so
2). restart Apache2 service;
3). put 'hello.py' script under path '%SRVROOT%/cgi-bin/', the script content:
4). open 'http://localhost/cgi-bin/hello.py' with browser, it works!