新增html模板

pull/30/head
unknown 5 years ago
parent 7af66e799d
commit 5eb5f1b1c3

@ -137,7 +137,9 @@ func main() {
if err := <-done; err != nil {
log.Fatal(err)
}
for {
log.Println("读取第几封信信体:")
inLine = readLineFromInput()
mesIndex, _ := strconv.Atoi(inLine)
mesSeqSet := new(imap.SeqSet)
@ -146,13 +148,13 @@ func main() {
var section imap.BodySectionName
items := []imap.FetchItem{section.FetchItem()}
messages = make(chan *imap.Message, 1)
bodyMsg := make(chan *imap.Message, 1)
go func() {
if err := c.Fetch(mesSeqSet, items, messages); err != nil {
if err := c.Fetch(mesSeqSet, items, bodyMsg); err != nil {
log.Fatal(err)
}
}()
msg := <-messages
msg := <-bodyMsg
if msg == nil {
log.Fatal("服务器没有返回信息")
}
@ -199,7 +201,8 @@ func main() {
log.Printf("Got attachment: %s\n", filename)
}
}
log.Println("结束!")
log.Printf("读取第 %d 封信, 结束!\n", mesIndex)
}
}
//从输入中读取一行

@ -0,0 +1,19 @@
package main
import (
"html/template"
"log"
"net/http"
)
func main(){
log.Println("listen on 8080...")
http.HandleFunc("/",index)
//监听端口
http.ListenAndServe(":8080", nil)
}
//输出首页
func index(w http.ResponseWriter, r *http.Request){
t,_:=template.ParseFiles("./tmpl/index.html")
t.Execute(w, nil)
}

@ -0,0 +1 @@
<h1>hello</h1>
Loading…
Cancel
Save