代码拉取完成,页面将自动刷新
// WebPanel project main.go
package main
import (
"fmt"
"github.com/elazarl/go-bindata-assetfs"
"html/template"
"log"
"net/http"
)
func ParseTemplate(name string) (*template.Template, error) {
t := template.New(name)
tpl, err := Asset("template/header.html")
t.Parse(string(tpl))
tpl, err = Asset("template/footer.html")
t.Parse(string(tpl))
tpl, err = Asset(fmt.Sprintf("template/%s.html", name))
t.Parse(string(tpl))
return t, err
}
func view_index(w http.ResponseWriter, r *http.Request) {
t, _ := ParseTemplate("index")
t.ExecuteTemplate(w, "content", nil)
}
func main() {
http.Handle("/static/", http.FileServer(&assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: ""}))
http.HandleFunc("/", view_index)
//err := http.ListenAndServe(":3000", nil) //设置监听的端口
err := http.ListenAndServeTLS(":3000", "/etc/pki/tls/certs/ca.crt", "/etc/pki/tls/private/ca.key", nil) //设置监听的端口
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。