I have been in DevOps related jobs for past 6 years dealing mainly with Kubernetes in AWS and on-premise as well. I spent quite a lot …
:date_long | 1 min Read
Go http.FileServer()
import (
"io"
"net/http"
)
func main() {
http.Handle("/", http.FileServer(http.Dir(".")))
http.HandleFunc("/tesla", teslaFromFileSystem)
http.ListenAndServe(":8080", nil)
}
func teslaFromFileSystem(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
io.WriteString(w, `<img src="tesla.jpg">`)
}