[Python 2.7] Hello World CGI HTTP Server
时间:2014-08-13 01:09:54
收藏:0
阅读:430
# CGI HTTP server
## Getting Started
Python 2.x is preferred to this simple demo. I‘m using Python 2.7 over windows.
## Starting a CGIHTTPServer
$ python -m CGIHTTPServer 8000Serving HTTP on 0.0.0.0 port 8000 ...
## CGI Script, Hello World
$ mkdir cgi-bin/
$ vim cgi-bin/index.pyprint "Content-Type: text/html" # HTML is followingprint # 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!
[Python 2.7] Hello World CGI HTTP Server,布布扣,bubuko.com
原文:http://blog.csdn.net/wxqee/article/details/38525965
评论(0)