1 Star 2 Fork 2

朋朋/binfs_web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 992 Bytes
一键复制 编辑 原始数据 按行查看 历史
wlx 提交于 2015-02-24 21:59 . init
// 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)
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/pongoflight/binfs_web.git
git@gitee.com:pongoflight/binfs_web.git
pongoflight
binfs_web
binfs_web
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385