2014-10-17 20:35
浏览 43


I want to print out the text message first and below the text, diplay the image. But I am getting http: multiple response.WriteHeader calls errors.

How do I serve iamges and text using one hadler in one single page?

func handler(w http.ResponseWriter, r *http.Request) {
  fmt.Fprint(w, "Hello, world!")
  fp := path.Join("images", "gopher.png")
  http.ServeFile(w, r, fp)

func main() {
  http.HandleFunc("/", handler)
  http.ListenAndServe(":3000", nil)

图片转代码服务由CSDN问答提供 功能建议

我想先在文本下方打印文本消息,然后显示图像。 但是我得到了< code> http:多个响应。WriteHeader调用</ code>错误。</ p>

如何在一个页面中使用一个hadler来提供图片和文本?</ p> < pre> func handler(w http.ResponseWriter,r * http.Request){ fmt.Fprint(w,“ Hello,world!”) fp:= path.Join(“ images”,“ gopher .png“) http.ServeFile(w,r,fp) } func main(){ http.HandleFunc(” /“,handler) http.ListenAndServe(”:3000“, nil) } </ code> </ pre> </ div>

1条回答 默认 最新

相关推荐 更多相似问题