forked from OpenPDU/openpdu
go on
This commit is contained in:
29
t/web.go
Normal file
29
t/web.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"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("/", statusPage)
|
||||
m.Get("/json/status", jsonStatus)
|
||||
m.Post("/json/outlet/:outlet/on", jsonOutletPowerON)
|
||||
m.Post("/json/outlet/:outlet/off", jsonOutletPowerOFF)
|
||||
m.Post("/json/outlet/:outlet/toggle", jsonOutletPowerToggle)
|
||||
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user