测试用CGI,名字为test.py,放在apache的cgi-bin目录下:
#!/usr/bin/python
import cgi
def main():
print "Content-type: text/html\n"
form = cgi.FieldStorage()
if form.has_key("ServiceCode") and form["ServiceCode"].value != "":
print "<h1>Hello",form["ServiceCode"].value,"</h1>"
else:
print "<h1>Error! Please enter first name.</h1>"
main()
python发送post和get请求
get请求:
使用get方式时,请求数据直接放在url中
普通的ruby程序可以用http/net包完成http的GET、POST请求,rails里面也可以这么做吧。require 'net/http'
url = URI.parse('http://www.rubyinside.com/test.cgi')
Net::HTTP.start(url.host, url.port) do |http|
req = Net::HTTP::Post.new(url.path)
req.set_form_data({ 'name' =>'David', 'age' =>'24' })
puts http.request(req).body
end
打开cmd,执行protoc.exe --java_out=. test.proto(注意test.proto前面要有空格),执行后,会生成一个test.java的类,将其放到你的项目中,并在你的项目中引用protobuf-java-2.5.0.jar至此环境配置完毕