Skip to content

Instantly share code, notes, and snippets.

@ejcx
Created March 23, 2019 05:01
Show Gist options
  • Select an option

  • Save ejcx/0c08a2f497768e8ed12e1addbcd54def to your computer and use it in GitHub Desktop.

Select an option

Save ejcx/0c08a2f497768e8ed12e1addbcd54def to your computer and use it in GitHub Desktop.

Revisions

  1. ejcx created this gist Mar 23, 2019.
    38 changes: 38 additions & 0 deletions flight.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    package main

    import (
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
    "time"
    )

    var (
    d []byte
    )

    func main() {
    go func() {
    for {
    resp, err := http.Get("https://www.unitedwifi.com/portal/r/getAllSessionData")
    if err != nil {
    log.Println(err)
    continue
    }
    buf, err := ioutil.ReadAll(resp.Body)
    if err != nil {
    log.Println(err)
    continue
    }
    d = buf
    time.Sleep(time.Second * 5)
    }
    }()

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "%s", d)
    })
    log.Fatal(http.ListenAndServe(":8080", nil))

    }