Created
October 26, 2020 00:12
-
-
Save Israel-Miles/58b066c7d81b2bd488dcbfcd1c1404de to your computer and use it in GitHub Desktop.
basic go server
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
// 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