new source promoted

This commit is contained in:
2019-10-27 22:56:00 +01:00
parent f781e24028
commit 93846dbbea
17 changed files with 52 additions and 383 deletions

29
source/web.go Normal file
View 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))
}