Created
May 3, 2018 08:40
-
-
Save vharsh/bf215504af1521cecc676b1d31ebbd02 to your computer and use it in GitHub Desktop.
Expose your directory's files over HTTP
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
// Good for a no nonsense file sharing across a network. | |
// This is an implementation of the similar functionality you get by doing `python -m SimpleHTTPServer` | |
// To use this you must compile this with a go compiler and pass the desired path to directory(to be hosted) as CLI arguments. | |
package main | |
import ( | |
"net/http" | |
"os" | |
) | |
func main() { | |
var dir string | |
if len(os.Args) > 1 { | |
dir = os.Args[1] | |
http.ListenAndServe(":8080", http.FileServer(http.Dir(dir))) | |
} else { | |
println("Usage ./fileserver /path/to/directory") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment