Skip to content

Commit cf32acc

Browse files
committed
use env PORT
1 parent db462a8 commit cf32acc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

main.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io/ioutil"
99
"log"
1010
"net/http"
11+
"os"
1112
"strings"
1213

1314
"github.com/gorilla/mux"
@@ -128,10 +129,15 @@ func main() {
128129
return nil
129130
})
130131

132+
port := os.Getenv("PORT")
133+
if port == "" {
134+
port = "8093"
135+
}
136+
131137
r := mux.NewRouter()
132138
r.HandleFunc("/isbn/{isbn}", IsbnAPI)
133-
fmt.Println("server running on http://localhost:8093/isbn/{$ISBN}")
139+
fmt.Printf("server running on http://localhost:%s/isbn/{$ISBN}", port)
134140

135-
http.ListenAndServe(":8093", r)
141+
http.ListenAndServe(fmt.Sprintf(":%s", port), r)
136142

137143
}

0 commit comments

Comments
 (0)