Created
April 8, 2017 19:52
-
-
Save ravidelcj/907b121111c8033c9197c0bf4104207a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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