package main import ( "fmt" "log" "net/http" "github.com/go-macaron/pongo2" "gopkg.in/macaron.v1" ) func startServer() { m := macaron.Classic() m.Use(pongo2.Pongoer()) m.Use(macaron.Static("static")) // m.Get("/", myHandler) m.Get("/", func(ctx *macaron.Context) { ctx.Data["pluglist"] = []Dictionary{ {"id": 1, "description": "p1"}, {"id": 2, "description": "p2"}, {"id": 3, "description": "p3"}, {"id": 4, "description": "p4"}, {"id": 5, "description": "p5"}, {"id": 6, "description": "p6"}, {"id": 7, "description": "p7"}, {"id": 8, "description": "p8"}, } ctx.HTML(200, "status") // 200 is the response code. }) m.Get("/json/status", func(ctx *macaron.Context) { p0, err := MyBoard.channelStatus(0) if err != nil { log.Fatal(err) } p1, err := MyBoard.channelStatus(1) if err != nil { log.Fatal(err) } p2, err := MyBoard.channelStatus(2) if err != nil { log.Fatal(err) } p3, err := MyBoard.channelStatus(3) if err != nil { log.Fatal(err) } p4, err := MyBoard.channelStatus(4) if err != nil { log.Fatal(err) } p5, err := MyBoard.channelStatus(5) if err != nil { log.Fatal(err) } p6, err := MyBoard.channelStatus(6) if err != nil { log.Fatal(err) } p7, err := MyBoard.channelStatus(7) if err != nil { log.Fatal(err) } p1 = p1 && p2 && p3 && p4 && p5 && p6 && p7 ctx.JSON(http.StatusOK, Dictionary{ "data": [][]string{ {"0", "p0", fmt.Sprint(p0)}, {"1", "p1", fmt.Sprint(p1)}, {"2", "p2", fmt.Sprint(p2)}, }, }) }) m.Get("/boards", func(ctx *macaron.Context) { ctx.HTML(200, "boards") // 200 is the response code. }) log.Println("Server is running...") log.Println(http.ListenAndServe("0.0.0.0:4000", m)) }