python-cgi-demo

简单的Python CGI 在linux平台实现
注意:路径是以当前路径为根目录 ,Python文件一般放在/cgi-bin/目录下
在linux命令行运行:python  -m  CGIHTTPServer  8000(端口号默认8000)
html文件名设为index.html 
测试:本机浏览器 输入 localhost:端口号

 1  #!/usr/bin/python
 2 #python文件
 3 import cgi
 4 
 5 show='''Content-Type:text/html

 6 <html>
 7 <head>
 8 <title>llllll</title></head>
 9 <body>
10 <p>hello world</p></body></html>
11 '''
12 print show
 1 <!DOCTYPE html>
 2 <html>
 3   <head>
 4     <meta charset="utf-8">
 5     <title>查询</title>
 6   </head>
 7   <body>
 8     <form class="" action="cgi-bin/a.py" >
 9         起点<input type="text" name="start" value="西二旗">
10         终点 <input type="text" name="end" value="中关村">
11         <input type="submit" name="name" value="提交">
12     </form>
13   </body>
14 </html>
原文地址:https://www.cnblogs.com/chengyunshen/p/7196193.html