Skip to content

Instantly share code, notes, and snippets.

@ravidelcj
Created April 8, 2017 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravidelcj/907b121111c8033c9197c0bf4104207a to your computer and use it in GitHub Desktop.
Save ravidelcj/907b121111c8033c9197c0bf4104207a to your computer and use it in GitHub Desktop.
func getFile(res http.ResponseWriter, req *http.Request) {
files, _ := ioutil.ReadDir("./publicFolder/")
res.Header().Set("Content-Type", "text/html; charset=utf-8")
myHtml := `
<!DOCTYPE html>
<html>
<head>
<title>
Home Network
</title>
</head>
<body>
<ul>`
for _, f := range files {
fmt.Println(f.Name())
myHtml += (`
<li>
<a href="./publicFolder/` + f.Name() + `" download="`+f.Name()+`" >` + f.Name() + `</a>
</li>`)
}
//
myHtml += (
`
</ul>
</body>
</html>
`)
io.WriteString(res, myHtml)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment