必须先感叹一句,GO语言太强了,自带的库很丰富,语法够简洁,即使没接触过GO,稍微学习一下就能用几十行代码做出个简单的web服务器。 由于foobar2000可以通过命令行进行操作,比如: foobar2000.exe /command:Next 就是切换到下一曲。利用这个特性,就能很轻易的实现远程操控foobar2000。 下面是GO语言的代码,文件名为foobar2k_web.go: package main import ( "os/exec" "fmt" "io" "net/http" "os" ) var service_port = ":9527" var service_path = "/foobar2k" var foobar2k_path = "d:\bin\foobar2000\foobar2000.exe" var fbcmd_map = map[string]string{"prev":"Previous","next":"Next","vdown":"Down","vup":"Up","playpause":"Play or pause"} func FB2KServer(w http.ResponseWriter, req *http.Request) { io.WriteString(w, "") io.WriteString(w, "") io.WriteString(w, "") io.WriteString(w, "<style type="&amp;quot;text/css&amp;quot;">div.bt {width:100px;height:100px;float:left;text-align:center;line-height:100px;background-color:green;}div.bt a{font-size:72px;color:white;font-weight:bold;text-decoration:none;}</style>") io.WriteString(w, "") io.WriteString(w, "") io.WriteString(w, "<div style="&amp;quot;width:500px;height:100px;margin:100px" auto;&quot;="">") io.WriteString(w, "<div class="&amp;quot;bt&amp;quot;"><a target="&amp;quot;_self&amp;quot;" href="&amp;quot;&quot;+service_path+&quot;?fbcmd=prev&amp;quot;">《</a></div>") io.WriteString(w, "<div class="&amp;quot;bt&amp;quot;"><a target="&amp;quot;_self&amp;quot;" href="&amp;quot;&quot;+service_path+&quot;?fbcmd=next&amp;quot;">》</a></div>") io.
阅读全文

作者的图片

jiazhoulvke


Coder

China