首页 > 编程语言 > 详细

[Python 2.7] Hello World CGI HTTP Server

时间:2015-09-10 20:51:45      阅读:276      评论:0      收藏:0      [点我收藏+]


# 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 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!



版权声明:本文博主原创文章,博客,未经同意不得转载。

[Python 2.7] Hello World CGI HTTP Server

原文:http://www.cnblogs.com/bhlsheji/p/4798925.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!