# CGI HTTP server
## Getting Started
Python 2.x is preferred to this simple demo. I‘m using Python 2.7 over windows.
* https://docs.python.org/2.7/library/cgihttpserver.html
* https://docs.python.org/2.7/library/cgi.html
## Starting a CGIHTTPServer
$ python -m CGIHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...
## CGI Script, Hello World
$ mkdir cgi-bin/
$ vim cgi-bin/index.py
print "Content-Type: text/html" # HTML is following
print # blank line, end of headers
print "<TITLE>CGI script output</TITLE>"
print "<H1>This is my first CGI script</H1>"
print "Hello, world!"
## Access
Browser the following link and a web page will return.
http://localhost:8000/cgi-bin/index.py
This is my first CGI script
Hello, world!
版权声明:本文博主原创文章,博客,未经同意不得转载。
时间: 2024-11-05 18:50:11