Last active
December 27, 2015 06:59
-
-
Save jself/7286131 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"path/filepath" | |
) | |
func main() { | |
dir, err := filepath.Abs(filepath.Dir(os.Args[0])) | |
if err != nil { | |
log.Fatal(err) | |
os.Exit(-1) | |
} | |
var portn = flag.Int("port", 8080, "The port to run the server on") | |
flag.Parse() | |
var port = fmt.Sprintf(":%d", *portn) | |
fmt.Println("Running server for", dir, "and port", port) | |
panic(http.ListenAndServe(":8080", http.FileServer(http.Dir(dir)))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment