首页 > 代码库 > [Python 2.7] Hello World CGI HTTP Server
[Python 2.7] Hello World CGI HTTP Server
# 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 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 headersprint "<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!
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。