main.go 315 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "net/http"
  4. "os"
  5. )
  6. func main() {
  7. port := getPort()
  8. wd, _ := os.Getwd()
  9. http.ListenAndServe(":"+port, http.FileServer(http.Dir(wd)))
  10. }
  11. func getPort() string {
  12. port := os.Getenv("PORT")
  13. if len(os.Args) > 1 {
  14. port = os.Args[1]
  15. }
  16. if len(port) == 0 {
  17. port = "3000"
  18. }
  19. return port
  20. }