GET
import json
from urllib import parse
from wsgiref.simple_server import make_server
def application(env, start_response):
# 定义文件请求类型和当前请求成功的code
start_response('200 ok', [('Content-Type', 'text/html')])
# 获取当前get请求的所有数据,返回是string类型
parmas = parse.parse_qs(env['QUERY_STRING'])
# 获取get中key为name的值
name = parmas.get('name', [''])[0]
no = parmas.get('no', [''])[0]
# 组成一个字典
dic = {'name': name,
'no': no}
return [json.dumps(dic)]
if __name__ == "__main__":
port = 5088
httpd = make_server('0.0.0.0', port, application)
print("serving http on port {}".format(str(port)))
httpd.serve_forever()
POST