Created
April 22, 2012 10:52
-
-
Save gotnix/2463453 to your computer and use it in GitHub Desktop.
Share you directory via http server by golang.
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
package main | |
import( | |
"net/http" | |
"fmt" | |
) | |
func main() { | |
var ( | |
dir string | |
port string | |
) | |
fmt.Printf("Please input which directory\nwhat you want to share, start with \"/\":\n") | |
fmt.Scanf("%s",&dir) | |
h := http.FileServer(http.Dir(dir)) | |
fmt.Printf("Please input port Number: \n") | |
fmt.Scanf("%s",&port) | |
http.ListenAndServe(":"+port, h) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment