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