port option
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -91,6 +92,9 @@ func TradesHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// ---------- Main ----------
|
||||
|
||||
func main() {
|
||||
port := flag.String("port", "8081", "port to listen on")
|
||||
flag.Parse()
|
||||
|
||||
http.HandleFunc("/styles.css", Styles)
|
||||
http.HandleFunc("/", Home)
|
||||
http.HandleFunc("/about", About)
|
||||
@@ -102,8 +106,8 @@ func main() {
|
||||
http.HandleFunc("/trades", TradesHandler)
|
||||
http.HandleFunc("/api/prices", PricesHandler)
|
||||
|
||||
fmt.Println("running on http://localhost:8081/")
|
||||
if err := http.ListenAndServe(":8081", nil); err != nil {
|
||||
fmt.Printf("running on http://localhost:%s/\n", *port)
|
||||
if err := http.ListenAndServe(":"+*port, nil); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user