Skip to content

Instantly share code, notes, and snippets.

@alefhsousa
Last active September 13, 2017 03:49
Show Gist options
  • Select an option

  • Save alefhsousa/bd13deca253affabb1088d41df9b646e to your computer and use it in GitHub Desktop.

Select an option

Save alefhsousa/bd13deca253affabb1088d41df9b646e to your computer and use it in GitHub Desktop.
Simple server for share static documents
package main
import (
"flag"
"log"
"net/http"
)
func main() {
port := flag.String("p", "9999", "port to serve on")
directory := flag.String("d", ".", "the directory of static file to host")
flag.Parse()
http.Handle("/", http.FileServer(http.Dir(*directory)))
log.Printf("Serving %s on HTTP port: %s\n", *directory, *port)
log.Fatal(http.ListenAndServe(":"+*port, nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment