Skip to content

Instantly share code, notes, and snippets.

@Israel-Miles
Created October 26, 2020 00:12
Show Gist options
  • Save Israel-Miles/58b066c7d81b2bd488dcbfcd1c1404de to your computer and use it in GitHub Desktop.
Save Israel-Miles/58b066c7d81b2bd488dcbfcd1c1404de to your computer and use it in GitHub Desktop.
basic go server
// A basic HTTP server.
// By default, it serves the current working directory on port 8080.
package main
import (
"flag"
"log"
"net/http"
)
var (
listen = flag.String("listen", ":8080", "listen address")
dir = flag.String("dir", ".", "directory to serve")
)
func main() {
flag.Parse()
log.Printf("listening on %q...", *listen)
err := http.ListenAndServe(*listen, http.FileServer(http.Dir(*dir)))
log.Fatalln(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment