Skip to content

Commit

Permalink
feat: added address flag
Browse files Browse the repository at this point in the history
  • Loading branch information
c1982 committed May 17, 2021
1 parent 17aeeeb commit cabb2c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package main

import "fmt"
import (
"flag"
"fmt"
)

func main() {
fmt.Println("http://localhost:8000")
RunPage()
address := flag.String("address", "localhost:8080", "--address=:8080 or --address=192.168.1.10:80")
flag.Parse()
fmt.Printf("http://%s\r\n", *address)
RunPage(*address)
}
7 changes: 5 additions & 2 deletions web.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
//go:embed pages/index.html
var IndexPage string

func RunPage() {
func RunPage(address string) {
http.HandleFunc("/datatransfers", func(w http.ResponseWriter, r *http.Request) {
billdate := r.URL.Query().Get("date")
if billdate == "" {
Expand Down Expand Up @@ -57,7 +57,10 @@ func RunPage() {
fmt.Fprintf(w, "%s", IndexPage)
})

http.ListenAndServe(":8000", nil)
err := http.ListenAndServe(address, nil)
if err != nil {
log.Fatal(err)
}
}

func GetDates(billdate string) (startdate, enddate string, err error) {
Expand Down

0 comments on commit cabb2c7

Please sign in to comment.