Created
October 15, 2019 06:27
-
-
Save vharsh/06f70a5af2aac3c2f9f2cf98374966b4 to your computer and use it in GitHub Desktop.
file
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] | |
} | |
port := ":8000" | |
if len(os.Args) > 2 { | |
port = ":" + os.Args[2] | |
} | |
http.ListenAndServe(port, http.FileServer(http.Dir(dir))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment