CGI - Common Gateway Interface

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

httpd usage;

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:

sample;

4). open 'http://localhost/cgi-bin/hello.py' with browser, it works!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容