Created
April 27, 2022 06:43
-
-
Save mash/1bcbbc56e28b673093c03483b277f3ba to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"fmt" | |
"log" | |
"net" | |
"net/http" | |
"os" | |
) | |
func main() { | |
dir, _ := os.Getwd() | |
port := os.Getenv("PORT") | |
if port == "" { | |
port = "0" | |
} | |
l, err := net.Listen("tcp4", ":"+port) | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Printf("listening on :%s\nOpen http://%s\n", l.Addr(), l.Addr().String()) | |
log.Fatal(http.Serve(l, http.FileServer(http.Dir(dir)))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment