例子:
#coding=utf-8
'''
Created on 2015-7-20
@author: xhw
@explain: 实现GET方法和POST方法请求
'''
from BaseHTTPServer import HTTPServer,BaseHTTPRequestHandler
import urllib
class ServerHTTP(BaseHTTPRequestHandler):
def do_GET(self):
path = self.path
print path
#拆分url(也可根据拆分的url获取Get提交才数据),可以将不同的path和参数加载不同的html页面,或调用不同的方法返回不同的数据,来实现简单的网站或接口
query = urllib.splitquery(path)
print query
self.send_response(200)
self.send_header("Content-type","text/html")
self.send_header("test","This is test!")
self.end_headers()
buf = '''<!DOCTYPE HTML>
<html>
<head><title>Get page</title></head>
<body>
<form action="post_page" method="pos