mirror of https://github.com/velour/catbase.git
Removing broken web component (for CI)
This commit is contained in:
parent
14b0e02235
commit
71ba0f4b2a
39
web/web.go
39
web/web.go
|
@ -1,39 +0,0 @@
|
||||||
package web
|
|
||||||
|
|
||||||
import (
|
|
||||||
"html/template"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Define the address which this service will respond
|
|
||||||
var addr string = "0.0.0.0:6969"
|
|
||||||
|
|
||||||
// path to the template files
|
|
||||||
var tmplPath string = "templates"
|
|
||||||
|
|
||||||
// Return an index of the web functions available
|
|
||||||
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
|
||||||
renderTemplate(w, r, "index", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to load and execute a template for the given site
|
|
||||||
func renderTemplate(w http.ResponseWriter, r *http.Request, tmpl string, data interface{}) {
|
|
||||||
t, err = template.ParseFiles(filepath.Join(tmplPath, tmpl+".html"))
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, "Could not load templates.", http.StatusInternalServerError)
|
|
||||||
log.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = t.Execute(w, data)
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, "Could not load templates.", http.StatusInternalServerError)
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
http.HandleFunc("/", indexHandler)
|
|
||||||
log.Fatal(http.ListenAndServe(addr, nil))
|
|
||||||
}
|
|
Loading…
Reference in New Issue