Last active
September 29, 2023 08:21
-
-
Save karl-gustav/7a54487094224eaddb76449e3db6b75a to your computer and use it in GitHub Desktop.
go webserver
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 | |
func main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hello world!") | |
}) | |
port := os.Getenv("PORT") | |
if port == "" { | |
port = "8080" | |
} | |
log.Println("Serving http://localhost:" + 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