FAQ
package main

import (
     "html/template"
     "net/http"
)

func main() {
     http.HandleFunc("/", test)
     http.ListenAndServe(":8083", nil)
}

func test(w http.ResponseWriter, r *http.Request) {
     index := template.Must(template.ParseFiles("index.html"))

     index.Execute(w, nil)
}


index.html
<!DOCTYPE html>
<html>
     <head>
         <title>Image</title>
     </head>
     <body>
          <img src="test.png" >
     </body>
<html>


Resource interpreted as Image but transferred with MIME type text/html:
"http://localhost:8083/test.png".

why can not I show the picture inside the img tag and why MIME type not
image/png and how can i fixed that



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dave Cheney at May 7, 2013 at 10:59 pm
    http.HandleFunc("/", test)

    matches every request, including /test.png.
    On Wed, May 8, 2013 at 4:07 AM, M7mD wrote:
    package main

    import (
    "html/template"
    "net/http"
    )

    func main() {
    http.HandleFunc("/", test)
    http.ListenAndServe(":8083", nil)
    }

    func test(w http.ResponseWriter, r *http.Request) {
    index := template.Must(template.ParseFiles("index.html"))

    index.Execute(w, nil)
    }


    index.html
    <!DOCTYPE html>
    <html>
    <head>
    <title>Image</title>
    </head>
    <body>
    <img src="test.png" >
    </body>
    <html>


    Resource interpreted as Image but transferred with MIME type text/html:
    "http://localhost:8083/test.png".

    why can not I show the picture inside the img tag and why MIME type not
    image/png and how can i fixed that



    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 7, '13 at 10:53p
activeMay 7, '13 at 10:59p
posts2
users2
websitegolang.org

2 users in discussion

M7mD: 1 post Dave Cheney: 1 post

People

Translate

site design / logo © 2022 Grokbase